mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-21 00:26:10 +02:00
Use strtr() instead of strtoupper() to avoid bogus results
For examle the tr_TR locale will upper-case "i" to the "latin capital letter i with dot above" İ.
This commit is contained in:
@@ -527,8 +527,13 @@ class Logger implements LoggerInterface, ResettableInterface
|
|||||||
*/
|
*/
|
||||||
public static function toMonologLevel($level)
|
public static function toMonologLevel($level)
|
||||||
{
|
{
|
||||||
if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) {
|
if (is_string($level)) {
|
||||||
return constant(__CLASS__.'::'.strtoupper($level));
|
// Contains chars of all log levels and avoids using strtoupper() which may have
|
||||||
|
// strange results depending on locale (for example, "i" will become "İ")
|
||||||
|
$upper = strtr($level, 'abcdefgilmnortuwy', 'ABCDEFGILMNORTUWY');
|
||||||
|
if (defined(__CLASS__.'::'.$upper)) {
|
||||||
|
return constant(__CLASS__ . '::' . $upper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $level;
|
return $level;
|
||||||
|
Reference in New Issue
Block a user