1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-20 08:06:19 +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:
Matthias Pigulla
2019-12-06 21:51:12 +00:00
parent ea216b0e2f
commit f8245696b3

View File

@@ -527,8 +527,13 @@ class Logger implements LoggerInterface, ResettableInterface
*/
public static function toMonologLevel($level)
{
if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) {
return constant(__CLASS__.'::'.strtoupper($level));
if (is_string($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;