Skip to content

Commit

Permalink
Merge pull request #1406 from mpdude/fix-tr-locale
Browse files Browse the repository at this point in the history
Fix a bug when using string-based loglevels in the `tr_TR` locale
  • Loading branch information
Seldaek committed Dec 7, 2019
2 parents ea216b0 + f824569 commit b928039
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,13 @@ public static function getLevelName($level)
*/
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;
Expand Down

0 comments on commit b928039

Please sign in to comment.