By kim.pepper on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.1.x
Introduced in version:
10.1.0
Issue links:
Description:
The procedural watchdog_exception() function has been deprecated.
A number of classes that were using watchdog_exception() now explicitly inject a logger to be able to pass to \Drupal\Core\Utility\Error::logException()
I. Basic usage
Before:
<?php
watchdog_exception('modulename', $exception);
?>After:
<?php
use Drupal\Core\Utility\Error;
$logger = \Drupal::logger('modulename');
Error::logException($logger, $exception);
?>II. Advanced usage:
Before:
<?php
watchdog_exception('modulename', $exception, 'My custom message @foo', ['@foo' => 'bar'], RfcLogLevel::CRITICAL, 'http://example.com');
?>After:
<?php
use Drupal\Core\Utility\Error;
use Psr\Log\LogLevel;
$logger = \Drupal::logger('modulename');
Error::logException($logger, $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], LogLevel::CRITICAL);
?>Impacts:
Module developers