DbLog doesn't explain how to use $context to create the operation links in the reports page

Created on 5 June 2019, over 5 years ago
Updated 2 September 2024, 4 months ago

API page: https://api.drupal.org/api/drupal/core%21modules%21dblog%21src%21Logger%...

The dblog module allows for an operation link on a log item. This is taken from $context['link'] as can be seen in node module:

    $node_link = $node->link($this->t('View'));
    $context = ['@type' => $node->getType(), '%title' => $node->label(), 'link' => $node_link];
    $t_args = ['@type' => node_get_type_label($node), '%title' => $node->link($node->label())];

    if ($insert) {
      $this->logger('content')->notice('@type: added %title.', $context);

However, this doesn't appear to be documented anywhere in dblog module. I'd expect it to be on the DbLog class in general, with a @see on the log method.

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Documentation 

Last updated 1 day ago

No maintainer
Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France O'Briat Nantes

    There's some info in \Drupal\Core\Logger\LoggerChannelInterface, but I agree that this item usage (and the other context ones) should be better documented, since it spreads on all logger usages.

  • 🇧🇷Brazil kleiton_rodrigues Americana/SP

    We may consider updating the documentation for the \Drupal\Core\Logger\LoggerChannelInterface interface
    to include practical examples of how to use $context, including the addition of operation links.
    This would ensure that the functionality is more accessible and understandable to everyone using the logging system.

Production build 0.71.5 2024