Error: Argument #2 ($logger) must be of type Drupal\Core\Logger\LoggerChannel

Created on 2 February 2024, 11 months ago
Updated 8 July 2024, 6 months ago

Problem/Motivation

When the module is enabled in sites using a logger channel class different than Drupal\Core\Logger\LoggerChannel interface, the following error appears: Argument #2 ($logger) must be of type Drupal\Core\Logger\LoggerChannel

Logger channel service's class may change depending on the project it's installed. For example, if the contrib module monolog is installed, the logger channel class changes to Drupal\monolog\Logger\LoggerInterfacesAdapter.

Steps to reproduce

- Install monolog.
- Install revision_cleanup.

Proposed resolution

In classes that requires logger channel service, require the LoggerChannelInterface instead of the specific LoggerChannel class.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

🇪🇸Spain omarlopesino

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024