Просмотр исходного кода

Merge pull request #1406 from mpdude/fix-tr-locale

Fix a bug when using string-based loglevels in the `tr_TR` locale
Jordi Boggiano 6 лет назад
Родитель
Сommit
b928039c23
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      src/Monolog/Logger.php

+ 7 - 2
src/Monolog/Logger.php

@@ -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;