Problem/Motivation
See #1289536-288: Switch Watchdog to a PSR-3 logging framework to #290 and https://github.com/php-fig/log/issues/8
Proposed resolution
Keep the current behavior, aka stick with RFC 5424 decimal levels.
For this to happen though, we should fork Psr\Log\LogLevel into Drupal\Core\Logger\RfcLogLevel and Psr\Log\LoggerTrait into Drupal\Core\Logger\RfcLoggerTrait and make our loggers (dblog and syslog) use those.
LoggerChannel should still use the PS3 LoggerTrait though and translate those values in its log() method, so that we are still compatible with any class that wants to log using PSR3 constants
Remaining tasks
Write the patch
User interface changes
None
API changes
WATCHDOG_* constants and watchdog_severity_levels() are removed
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | drupal-2267545-20.patch | 25.24 KB | ParisLiakos |
| #21 | interdiff-2267545.txt | 3.31 KB | ParisLiakos |
| #19 | drupal-2267545-18.patch | 24.18 KB | ParisLiakos |
| #19 | interdiff-2267545.txt | 1.73 KB | ParisLiakos |
| #17 | drupal-2267545-16.patch | 23.73 KB | ParisLiakos |
Comments
Comment #1
ParisLiakos commentedComment #2
ParisLiakos commentedComment #3
ParisLiakos commentedComment #4
ParisLiakos commentedComment #5
Crell commentedSince the values behind the constants are transparent to module developers, I don't see why we would continue to use or own rather than the standard's. We're calling our logger PSR-3, modules should use PSR-3's interface in the type hint... why add this asterisk to that?
Comment #6
catchWe do not have 'our own' values, we have values consistent with RFC 3164.
PSR-3 does not require using the constant values from the interface - those are just there as examples. Implementors of PSR-3 are free to use whichever constant values they like.
https://github.com/php-fig/log/issues/8 and https://github.com/php-fig/log/pull/11 both attempted to bring PSR-3 into line with common standards, but were rejected. However it's clear from those that the constant values are not considered part of PSR-3 anyway.
Additionally they aren't transparent to module developers, if you implement a logger for syslog etc., then you'd have to convert from the arbitrary strings to the decimal values anyway.
Comment #7
catchAlso note that monolog uses ints: https://github.com/Seldaek/monolog/blob/master/src/Monolog/Logger.php
Comment #8
sunCreated a PR for php-fig/log: https://github.com/php-fig/log/pull/21
My impression is that there is a good level of support for doing that change (which is reasonable, because the vast majority of projects are using the IETF RFC 5424 integer severity levels), but I yet have to figure out the FIG process. Last comment on the PR was to create a separate thread on the mailing list.
Comment #9
ParisLiakos commentedsun opened https://groups.google.com/forum/#!topic/php-fig/Rc5YDhNdGz4
but dunno whether we actually want to a) wait for that or b) go on here with the proposed solution, and if the change is accepted we merge it later?
i would say lets go with b)
Comment #10
ParisLiakos commentedComment #11
ParisLiakos commentedComment #12
ParisLiakos commentedHere is a patch, which also deprecated WATCHDOG_* constants and watchdog_severity_levels()
I am not sure if there is any value keeping watchdog_severity_levels() till Drupal 9.0, but well thats not up to me to decide
Comment #14
ParisLiakos commenteduhm, forgot use statement
Comment #15
catchThank for reviving this one! Forgot we still had this mess...
Don't think this should use t() - does it have to be a static method on this class or could it move elsewhere?
I'd be fine with converting the remaining uses of the WATCHDOG_* constants and removing them in this patch. They are only used internally at this point so I don't consider them part of the module-facing API. (Short section on this in #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase?).
Comment #16
ParisLiakos commentedthanks for the feedback!
I was suprised to only see the WATCHDOG_* constants being used in so few places..So..i went ahead and removed them (but i doubt drush will like it)
Well the only other place that could make sense is introducing a
logger.log_levelsservice, moving this there, and also splitting the mapping logic fromLoggerChannelthere.Is it worth doing?
Comment #17
ParisLiakos commentedhmm, the actual files!
Comment #18
catchNot sure that's worth doing, or could be a follow-up - it's not the important thing being fixed here.
Could we use TranslationWrapper or Drupal::translation()->translate() though so the dependency is more explicit?
Comment #19
ParisLiakos commentedDrupal::translation()->translate()cant be used because strings wont be picked up by the extractor.But TranslationWrapper is fine
Comment #20
catchCan also drop this as dead code I think.
responsible for
Otherwise looks great now.
Comment #21
ParisLiakos commentedthank you for the quick reviews!
Comment #22
jonhattan@ParisLiakos please open an issue in Drush's queue once this gets committed so we can keep drush in sync. It should be easy to fix - we have watchdog constants isolated in Drupal version specific engines.
Comment #23
ParisLiakos commented@jonhattan: nice! drush has no problems as proved already by testbot ;)
updating title since i think thats the direction now
Comment #24
catchCan't see anything else to complain about. so RTBC.
Comment #25
alexpottCommitted b82e28d and pushed to 8.0.x. Thanks!
https://www.drupal.org/node/2270941 needs updating now
Comment #27
ParisLiakos commentedthanks, i updated the change notice.
I noticed though that the patch added an empty file unwillingly :(
can we remove it?
git rm core/lib/Drupal/Core/Logger/LogLevelMapper.phpComment #29
alexpottRemoved empty file - a9f0c06 and pushed to 8.0.x. Thanks!