diff --git a/core/core.services.yml b/core/core.services.yml index 6b335f1..e1fed41 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -125,8 +125,6 @@ services: - [setContainer, ['@service_container']] logger.channel.default: class: Drupal\Core\Logger\LoggerChannel - calls: - - [setRequest, ['@?request']] tags: - { name: logger_channel } settings: diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index a508627..2750cf8 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1540,54 +1540,11 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia * @see hook_watchdog() */ function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG_NOTICE, $link = NULL) { - global $user, $base_root; - - static $in_error_state = FALSE; - - // It is possible that the error handling will itself trigger an error. In that case, we could - // end up in an infinite loop. To avoid that, we implement a simple static semaphore. - if (!$in_error_state && function_exists('module_implements')) { - $in_error_state = TRUE; - - // The user object may not exist in all conditions, so 0 is substituted if needed. - $user_uid = isset($user) ? $user->id() : 0; - - // Prepare the fields to be logged - $log_entry = array( - 'type' => $type, - 'message' => $message, - 'variables' => $variables, - 'severity' => $severity, - 'link' => $link, - 'user' => $user, - 'uid' => $user_uid, - 'request_uri' => '', - 'referer' => '', - 'ip' => '', - // Request time isn't accurate for long processes, use time() instead. - 'timestamp' => time(), - ); - - try { - $request = Drupal::request(); - $log_entry['request_uri'] = $request->getUri(); - $log_entry['referer'] = $request->headers->get('Referer', ''); - $log_entry['ip'] = $request->getClientIP(); - } - catch (\InvalidArgumentException $e) { - // We are not in a request context. - } - - // Call the logging hooks to log/process the message - foreach (module_implements('watchdog') as $module) { - $function = $module . '_watchdog'; - $function($log_entry); - } - - // It is critical that the semaphore is only cleared here, in the parent - // watchdog() call (not outside the loop), to prevent recursive execution. - $in_error_state = FALSE; + $variables = $variables ?: array(); + if ($link) { + $variables['link'] = $link; } + Drupal::service('logger.factory')->getLogger($type)->log($severity, $message, $variables); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php index 014b657..b6520a2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php @@ -48,7 +48,7 @@ function testEntityInfoChanges() { /** * Tests entity info cache after enabling a module with a dependency on an entity providing module. * - * @see entity_cache_test_watchdog() + * @see entity_cache_test_modules_enabled() */ function testEntityInfoCacheModulesEnabled() { module_enable(array('entity_cache_test'));