[GH-ISSUE #1571] About toMonologLevel() method - bug here or intentionally coded like this? #672

Closed
opened 2026-03-04 02:16:52 +03:00 by kerem · 1 comment
Owner

Originally created by @juan-morales on GitHub (Jul 27, 2021).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1571

Monolog version 2

File: Logger.php

Method: public static function toMonologLevel($level): int

I can see that passing something like toMonologLevel("123") returns 123. PSR-3 is actually achieved (for this case) on the public static function getLevelName(int $level): string when we throw an exception if the level is unknown.

I also see that toMonologLevel() is also used everywhere as a mechanism to get a valid monolog level (is used mainly on handlers).

So ... are we missing something here? What is the point to return 123 when "123" is passd to this method?

Do we need to fix this? Please let me know I can prepare Pull-Request ASAP .... also one more question .... is getLevelName() the right place to actually verify the level provided ???

Ideas/Healthy Discussions ... welcome.

Originally created by @juan-morales on GitHub (Jul 27, 2021). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1571 Monolog version 2 File: `Logger.php` Method: `public static function toMonologLevel($level): int` I can see that passing something like `toMonologLevel("123")` returns 123. PSR-3 is actually achieved (for this case) on the `public static function getLevelName(int $level): string` when we throw an exception if the level is unknown. I also see that `toMonologLevel()` is also used everywhere as a mechanism to get a valid monolog level (is used mainly on handlers). So ... are we missing something here? What is the point to return 123 when "123" is passd to this method? Do we need to fix this? Please let me know I can prepare Pull-Request ASAP .... also one more question .... is `getLevelName()` the right place to actually verify the level provided ??? Ideas/Healthy Discussions ... welcome.
kerem 2026-03-04 02:16:52 +03:00
  • closed this issue
  • added the
    Support
    label
Author
Owner

@Seldaek commented on GitHub (Sep 14, 2021):

The point is that we want to allow people extending the Logger class to provide their own levels, so unknown levels should be let through unharmed, even though it's not PSR-3 compliant. So as far as I can tell it's all fine as is.. but if you see a problem please explain :)

<!-- gh-comment-id:919151532 --> @Seldaek commented on GitHub (Sep 14, 2021): The point is that we want to allow people extending the Logger class to provide their own levels, so unknown levels should be let through unharmed, even though it's not PSR-3 compliant. So as far as I can tell it's all fine as is.. but if you see a problem please explain :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#672
No description provided.