Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 3 additions & 47 deletions NotFoundActivationStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,11 @@

namespace Symfony\Bundle\MonologBundle;

use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy as BridgeNotFoundActivationStrategy;

/**
* Activation strategy that ignores 404s for certain URLs
*
* Configure with:
*
* monolog:
* handlers:
* main:
* type: fingers_crossed
* action_level: error
* handler: nested
* excluded_404s:
* - ^/foo/
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @deprecated
*/
class NotFoundActivationStrategy extends ErrorLevelActivationStrategy
class NotFoundActivationStrategy extends BridgeNotFoundActivationStrategy
{
private $blacklist;
private $request;

public function __construct(array $excludedUrls, $actionLevel)
{
parent::__construct($actionLevel);
$this->blacklist = '{('.implode('|', $excludedUrls).')}i';
}

public function isHandlerActivated(array $record)
{
$isActivated = parent::isHandlerActivated($record);
if (
$isActivated
&& $this->request
&& isset($record['context']['exception'])
&& $record['context']['exception'] instanceof HttpException
&& $record['context']['exception']->getStatusCode() == 404
) {
return !preg_match($this->blacklist, $this->request->getPathInfo());
}

return $isActivated;
}

public function setRequest(Request $req = null)
{
$this->request = $req;
}
}
2 changes: 1 addition & 1 deletion Resources/config/monolog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<parameter key="monolog.handler.error_log.class">Monolog\Handler\ErrorLogHandler</parameter>
<parameter key="monolog.handler.loggly.class">Monolog\Handler\LogglyHandler</parameter>
<parameter key="monolog.handler.logentries.class">Monolog\Handler\LogEntriesHandler</parameter>
<parameter key="monolog.activation_strategy.not_found.class">Symfony\Bundle\MonologBundle\NotFoundActivationStrategy</parameter>
<parameter key="monolog.activation_strategy.not_found.class">Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy</parameter>

<parameter key="monolog.handler.fingers_crossed.class">Monolog\Handler\FingersCrossedHandler</parameter>
<parameter key="monolog.handler.fingers_crossed.error_level_activation_strategy.class">Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy</parameter>
Expand Down
51 changes: 0 additions & 51 deletions Tests/NotFoundActivationStrategyTest.php

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.3.2",
"symfony/monolog-bridge": "~2.3",
"symfony/monolog-bridge": "~2.6",
"symfony/dependency-injection": "~2.3",
"symfony/config": "~2.3",
"symfony/http-kernel": "~2.3",
Expand Down