mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-23 17:46:09 +02:00
Add support for PSR-3 levels to all public APIs accepting levels, fixes #421
This commit is contained in:
@@ -37,7 +37,7 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
*/
|
||||
public function __construct($level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
$this->level = $level;
|
||||
$this->setLevel($level);
|
||||
$this->bubble = $bubble;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
*/
|
||||
public function setLevel($level)
|
||||
{
|
||||
$this->level = $level;
|
||||
$this->level = Logger::toMonologLevel($level);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -63,11 +63,13 @@ class FilterHandler extends AbstractHandler
|
||||
public function setAcceptedLevels($minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY)
|
||||
{
|
||||
if (is_array($minLevelOrList)) {
|
||||
$acceptedLevels = $minLevelOrList;
|
||||
$acceptedLevels = array_map('Monolog\Logger::toMonologLevel', $minLevelOrList);
|
||||
} else {
|
||||
$acceptedLevels = array_filter(Logger::getLevels(), function ($level) use ($minLevelOrList, $maxLevel) {
|
||||
$minLevelOrList = Logger::toMonologLevel($minLevelOrList);
|
||||
$maxLevel = Logger::toMonologLevel($maxLevel);
|
||||
$acceptedLevels = array_values(array_filter(Logger::getLevels(), function ($level) use ($minLevelOrList, $maxLevel) {
|
||||
return $level >= $minLevelOrList && $level <= $maxLevel;
|
||||
});
|
||||
}));
|
||||
}
|
||||
$this->acceptedLevels = array_flip($acceptedLevels);
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Monolog\Handler\FingersCrossed;
|
||||
|
||||
use Monolog\Logger;
|
||||
|
||||
/**
|
||||
* Channel and Error level based monolog activation strategy. Allows to trigger activation
|
||||
* based on level per channel. e.g. trigger activation on level 'ERROR' by default, except
|
||||
@@ -42,8 +44,8 @@ class ChannelLevelActivationStrategy implements ActivationStrategyInterface
|
||||
*/
|
||||
public function __construct($defaultActionLevel, $channelToActionLevel = array())
|
||||
{
|
||||
$this->defaultActionLevel = $defaultActionLevel;
|
||||
$this->channelToActionLevel = $channelToActionLevel;
|
||||
$this->defaultActionLevel = Logger::toMonologLevel($defaultActionLevel);
|
||||
$this->channelToActionLevel = array_map('Monolog\Logger::toMonologLevel', $channelToActionLevel);
|
||||
}
|
||||
|
||||
public function isHandlerActivated(array $record)
|
||||
|
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Monolog\Handler\FingersCrossed;
|
||||
|
||||
use Monolog\Logger;
|
||||
|
||||
/**
|
||||
* Error level based activation strategy.
|
||||
*
|
||||
@@ -22,7 +24,7 @@ class ErrorLevelActivationStrategy implements ActivationStrategyInterface
|
||||
|
||||
public function __construct($actionLevel)
|
||||
{
|
||||
$this->actionLevel = $actionLevel;
|
||||
$this->actionLevel = Logger::toMonologLevel($actionLevel);
|
||||
}
|
||||
|
||||
public function isHandlerActivated(array $record)
|
||||
|
@@ -65,8 +65,8 @@ class PushoverHandler extends SocketHandler
|
||||
$this->token = $token;
|
||||
$this->users = (array) $users;
|
||||
$this->title = $title ?: gethostname();
|
||||
$this->highPriorityLevel = $highPriorityLevel;
|
||||
$this->emergencyLevel = $emergencyLevel;
|
||||
$this->highPriorityLevel = Logger::toMonologLevel($highPriorityLevel);
|
||||
$this->emergencyLevel = Logger::toMonologLevel($emergencyLevel);
|
||||
$this->retry = $retry;
|
||||
$this->expire = $expire;
|
||||
}
|
||||
|
Reference in New Issue
Block a user