Problem/Motivation
Drupal has a map of PSR3 log level constants to RFC 5424 log level constants, but hides it in a protected variable. This map should arguably be available as a constant.
Steps to reproduce
Proposed resolution
Deprecate the Drupal\Core\Logger\LoggerChannel::$levelTranslation protected variable in favor of a new constant Drupal\Core\Logger\LoggerChannel::LEVEL_TRANSLATION (or Drupal\Core\Logger\LoggerChannel::LEVEL_MAP)
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3432889-nr-bot.txt | 3.86 KB | needs-review-queue-bot |
Issue fork drupal-3432889
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mfbComment #4
smustgrave commentedChange to a constant makes sense.
Comment #5
mstrelan commentedWonder if we'd be better off making RfcLogLevel in to an enum and move the mapping to a function there. Setting NR for the idea, please set to NW if you agree or back to RTBC if not.
Comment #6
mfb@mstrelan I think you're suggesting an API change, if the RfcLogLevels would be objects rather than simple constants? That doesn't seem worth the developer friction to do.
Ok, I guess you could have an enum that also has the original constants pointing to the enum values, and there would be no API change, but then, what's the point?
Note also that Drupal\Core\Logger\RfcLogLevel is basically drupal's (moar RFC-compliant) version of Psr\Log\LogLevel, so it seems reasonable for them to have the same architecture.
Comment #8
mstrelan commentedThis is what I had in mind, happy to be told it's not worth it, just thought it was worth considering.
https://git.drupalcode.org/project/drupal/-/merge_requests/7178
Comment #9
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #10
mfb@mstrelan: Seems not worth it for the reasons I said in #6 but, if you want to discuss you could open a new issue? It seems only tangentially related to this issue, which was just to make the level map available, not to change any public APIs.
Comment #11
mfbWell, in the contrib module that this would've been useful for, I ended up introducing my own LogLevel enum to manage all the log level logic :)
So, I don't really need this anymore; feel free to close this issue as far as I'm concerned (or, perhaps the original feature request could still be useful for other developers).
Comment #12
quietone commentedThis looks familiar. Searching found an earlier issue for this which I closed as a duplicate.
Comment #13
mfb@quietone I actually suggested closing this issue, as it was pretty trivial to copy the map into two contrib modules where this feature could've been useful. Btw, I don't see how that other issue is a duplicate?