mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 16:15:49 +03:00
[GH-ISSUE #421] Support for PSR3 LogLevel? #144
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#144
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @polyfractal on GitHub (Sep 16, 2014).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/421
This issue was raised over at the Elasticsearch-PHP library: https://github.com/elasticsearch/elasticsearch-php/issues/125
The library is instantiating Monolog with a handler and a processor. Importantly, the logging level is being set with the LogLevel PSR3 class:
This proves problematic, since it seems Monolog is using it's own
Loggerclass for log level enum instead ofLogLevel?Is there a better way to configure Monolog in a way that still allows interoperability with other loggers? I'm happy to convert the
LogLevelenum into theLoggerenum if there isn't another way, but wanted to make sure I wasn't doing something silly :)@stof commented on GitHub (Sep 20, 2014):
PSR-3 log levels are support for calling code, and are converted to Monolog levels. So the handler should always use Monolog levels to handle the level filtering, as it is what it will get
@stof commented on GitHub (Sep 20, 2014):
And the reason why all Monolog internals does not use PSR-3 constants is simple: Monolog was written at least 2 years before PSR-3
@polyfractal commented on GitHub (Sep 22, 2014):
Ah, that makes sense :) Thanks for the help!
Would it be possible to add a static "helper" method to Monolog that converts from PSR3
LogLevelto Monolog'sLogLevel? E.g. ES-PHP users configure withLogLevel, internally the library calls the helper shim to convertLogLeveltoLoggerand then instantiates the handler chain using the appropriateLoggervalues.Even though the handler instantiation isn't "user land code", it's still a public API which things like the ES library interact with.
I can easily add a helper shim to ES-PHP, but if it was in Monolog that would be even better so that changes in Monolog don't break ES-PHP :)
@Seldaek commented on GitHub (Sep 22, 2014):
Any breaking changes to the log level will happen in 2.0 (if there are changes at all, it will be to normalize on the PSR-3 levels I suppose). If you require monolog ~1.0 you're safe.
That said yes it would be a good idea to add support for PSR-3 levels already in a 1.x release to make migration to a 2.0 easier. They don't conflict so it should be kinda easy to support them on all external/public API points.
@polyfractal commented on GitHub (Sep 23, 2014):
Great, thanks! I'll add a shim in ES-PHP and keep an eye on Monolog for similar functionality in the future (or just 2.0)
@polyfractal commented on GitHub (Sep 30, 2014):
Awesome! Thanks for the quick turnaround on this :)
@Seldaek commented on GitHub (Sep 30, 2014):
1.11 is tagged so you could depend on monolog
~1.11in ES-PHP if you want to drop your shim.