From b12cc0c74d3ee0cf431c6956a3075ee2105d955b Mon Sep 17 00:00:00 2001 From: Herb v/d Dool Date: Tue, 14 Feb 2023 16:46:37 -0500 Subject: [PATCH] dev/core#4127 move is_drupal to use userSystem logger --- CRM/Core/Error.php | 8 +------- CRM/Utils/System/Base.php | 3 ++- CRM/Utils/System/Drupal8.php | 9 +++++++++ CRM/Utils/System/DrupalBase.php | 6 +++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index bb39511f4a..1e0a718401 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -598,13 +598,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { } if (!empty(\Civi::$statics[__CLASS__]['userFrameworkLogging'])) { - // should call $config->userSystem->logger($message) here - but I got a situation where userSystem was not an object - not sure why - if ($config->userSystem->is_drupal and function_exists('watchdog')) { - watchdog('civicrm', '%message', ['%message' => $message], $priority ?? WATCHDOG_DEBUG); - } - elseif ($config->userSystem->is_drupal and CIVICRM_UF == 'Drupal8') { - \Drupal::logger('civicrm')->log($priority ?? \Drupal\Core\Logger\RfcLogLevel::DEBUG, '%message', ['%message' => $message]); - } + $config->userSystem->logger($message, $priority); } return $str; diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 0b88f721b2..450618f9b1 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -923,8 +923,9 @@ abstract class CRM_Utils_System_Base { * Log error to CMS. * * @param string $message + * @param string|NULL $priority */ - public function logger($message) { + public function logger($message, $priority = NULL) { } /** diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index d5a6034015..f3d6e41047 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -537,6 +537,15 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { return 'sidebar_first'; } + /** + * @inheritDoc + */ + public function logger($message, $priority = NULL) { + if (CRM_Core_Config::singleton()->userFrameworkLogging) { + \Drupal::logger('civicrm')->log($priority ?? \Drupal\Core\Logger\RfcLogLevel::DEBUG, '%message', ['%message' => $message]); + } + } + /** * @inheritDoc */ diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index e65c03d200..b7082dcdc4 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -269,9 +269,9 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { /** * @inheritDoc */ - public function logger($message) { - if (CRM_Core_Config::singleton()->userFrameworkLogging && function_exists('watchdog')) { - watchdog('civicrm', '%message', ['%message' => $message], NULL, WATCHDOG_DEBUG); + public function logger($message, $priority = NULL) { + if (CRM_Core_Config::singleton()->userFrameworkLogging) { + watchdog('civicrm', '%message', ['%message' => $message], $priority ?? WATCHDOG_DEBUG); } } -- 2.25.1