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.

CommentFileSizeAuthor
#3 2780499-3.patch526 bytesAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Anonymous’s picture

Status: Active » Needs review
FileSize
526 bytes

The 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?

dawehner’s picture

Mh, this is what LoggerChannelInterface for itself says:

 * This interface defines the full behavior of the central Drupal logger
 * facility. However, when writing code that does logging, use the generic
 * \Psr\Log\LoggerInterface for typehinting instead (you shouldn't need the
 * methods here).

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue tags: +Bug Smash Initiative

The 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.

Spokje’s picture

Status: Needs review » Closed (works as designed)

Looking 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.