Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MonologBundle] Added FirePHPHandler support
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/Symfony/Bundle/MonologBundle/Logger/FirePHPHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\MonologBundle\Logger; | ||
|
||
use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler; | ||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* FirePHPHandler. | ||
* | ||
* @author Jordi Boggiano <j.boggiano@seld.be> | ||
*/ | ||
class FirePHPHandler extends BaseFirePHPHandler | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $headers = array(); | ||
|
||
/** | ||
* @var Response | ||
*/ | ||
private $response; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function sendHeader($header, $content) | ||
{ | ||
if ($this->response) { | ||
$this->response->headers->set($header, $content); | ||
} else { | ||
$this->headers[$header] = $content; | ||
} | ||
} | ||
|
||
/** | ||
* Adds the headers to the response once it's created | ||
*/ | ||
public function onCoreResponse(FilterResponseEvent $event) | ||
{ | ||
$this->response = $event->getResponse(); | ||
foreach ($this->headers as $header => $content) { | ||
$this->response->headers->set($header, $content); | ||
} | ||
$this->headers = array(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters