mglaman / drupal-change-record-triage

Used to triage Drupal change records to ensure phpstan-drupal, drupal-rector, and upgrade_status have appropriate issues.
MIT License
6 stars 0 forks source link

watchdog_exception() deprecated #557

Open github-actions[bot] opened 1 year ago

github-actions[bot] commented 1 year ago

https://www.drupal.org/node/2932520

Introduced in branch/version: 10.1.x / 10.1.0

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()

Before, in a module called 'update':

Basic usage:

<?php
watchdog_exception('update', $exception);
?>

After:

<?php
use \Drupal\Core\Utility\Error;

$logger = \Drupal::logger('update');
Error::logException($logger, $exception);
?>

Advanced usage:

Before:

<?php
watchdog_exception('update', $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('update');
Error::logException($logger, $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], LogLevel::CRITICAL);
?>
bbrala commented 10 months ago

Implemented this: https://github.com/mglaman/drupal-change-record-triage/issues/557