Skip to content

Commit

Permalink
[MonologBridge] Fixed the WebProcessor
Browse files Browse the repository at this point in the history
The WebProcessor can now be registered as a kernel.request listener to
get the request instead of passing it as a constructor argument, which
was broken as the request is not yet available when the logger is
instantiated.
  • Loading branch information
stof committed Apr 23, 2012
1 parent dad9ccd commit e173dfe
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Processor/WebProcessor.php
Expand Up @@ -13,6 +13,8 @@

use Monolog\Processor\WebProcessor as BaseWebProcessor;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
* WebProcessor override to read from the HttpFoundation's Request
Expand All @@ -21,8 +23,16 @@
*/
class WebProcessor extends BaseWebProcessor
{
public function __construct(Request $request)
public function __construct()
{
parent::__construct($request->server->all());
// Pass an empty array as the default null value would access $_SERVER
parent::__construct(array());
}

public function onKernelRequest(GetResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
$this->serverData = $event->getRequest()->server->all();
}
}
}

0 comments on commit e173dfe

Please sign in to comment.