README suggests wrong format to drupal dblog

Created on 3 May 2022, almost 3 years ago
Updated 13 February 2025, 2 months ago

We configured our site based on README file.
Probably after change to PHP 8 we don't see logs in watchdog anymore. So I debugged and I found that the module silently failed in MonologLoggerChannelFactory::getHandlers method in

// Nested syntax.
    if (array_key_exists('handlers', $config)) {
      try {
        $handlers = array_map(function (array $handler): array {
          return [
            'name' => $handler['name'] ?? $handler,
            'formatter' => $handler['formatter'] ?? NULL,
            'processors' => $handler['processors'] ?? $this->container->getParameter(self::PROCESSORS_KEY),
          ];
        }, $config['handlers']);
      }
      catch (\Throwable $e) {
        return OptionalLogger::none();
      }
    }

My monolog.service.yml was:

parameters:
  monolog.channel_handlers:
    default:
      handlers: ['drupal.dblog', 'stream']
      formatter: 'minimal_line'

I should change to:

parameters:
  monolog.channel_handlers:
    default:
      handlers:
        - name: 'drupal.dblog'
          formatter: 'minimal_line'
        - name: 'stream'
          formatter: 'minimal_line'

The previous version failed because the code expected that $handler will be array(typecast in function argument list.)
I suggest to change the example in README where it suggests how to enable drupal logging.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Documentation

Created by

🇭🇺Hungary segi

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.

  • First commit to issue fork.
Production build 0.71.5 2024