API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal.php/function/Drupa...
Looking at Drupal::logger, the only place the docs lead you to is https://api.drupal.org/api/drupal/vendor%21psr%21log%21Psr%21Log%21Logge....
Which is vendor documentation and completely inadequate for the purposes here.
For one thing, Drupal logger channels allow Drupal t()-style placeholders, whereas this says only:
> The message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo".
For another, the methods have no parameter documentation and don't refer back to the interface which does document them.
Drupal::logger() should probably have a @see to Drupal's own implementation of this.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2780499-3.patch | 526 bytes | Anonymous (not verified) |
Comments
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedThe interface that is returned, actually is \Drupal\Core\Logger\LoggerChannelInterface. However, as the docs on that interface state, \Psr\Log\LoggerInterface should be used when writing logging code for the typehinting to work. I think we should point to the former, which explains rather well what a developer should do when writing a custom logger. I changed it in the patch attached.
The use of Drupal placeholders using the $context parameter is not general, let alone a requirement at that level of abstraction. We probably would want to document that specifically on the DbLog and SysLog methods? I'm not sure. For reference, the placeholder options are explained on FormattableMarkup::placeholderFormat().
The use of t() is not really a logging specific thing. I'm not sure if we want to explain that there, but I couldn't find examples either. For that, we might expand the documentation page for logging?
Comment #4
dawehnerMh, this is what
LoggerChannelInterface
for itself says:Comment #14
quietone CreditAttribution: quietone as a volunteer commentedThe documentation referred to in #4 was added in #2535192: Security: LoggerChannelInterface doxygen needs a little love
The use of the \Psr\Log\LoggerInterface for the type hint was questioned in #2535192-14: Security: LoggerChannelInterface doxygen needs a little love point 1 and that was answered in #2535192-15: Security: LoggerChannelInterface doxygen needs a little love. And that followed up with improvements to the text. According to that this documentation is correct and there is nothing to do here. this is working as designed.
I want to be sure, so asking in #bugsmash.
Comment #15
SpokjeLooking at "the evidence" provided by @quietone mostly, and also the fact that nobody chimed in on this or anything related I could find with my d.o-search capabilities, I agree with this is working as designed. Closing as such.
Feel free to re-open if you disagree.