mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-22 00:56:08 +02:00
Add support for PSR-3 levels to all public APIs accepting levels, fixes #421
This commit is contained in:
@@ -388,6 +388,21 @@ class Logger implements LoggerInterface
|
||||
return static::$levels[$level];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts PSR-3 levels to Monolog ones if necessary
|
||||
*
|
||||
* @param string|int Level number (monolog) or name (PSR-3)
|
||||
* @return int
|
||||
*/
|
||||
public static function toMonologLevel($level)
|
||||
{
|
||||
if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) {
|
||||
return constant(__CLASS__.'::'.strtoupper($level));
|
||||
}
|
||||
|
||||
return $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the Logger has a handler that listens on the given level
|
||||
*
|
||||
|
Reference in New Issue
Block a user