From 82073f7bb13fb632c25236aae72d8ebf83ff54eb Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 26 Apr 2021 17:23:13 +1200 Subject: [PATCH] Fix enotice when Log service is swapped out This function is calling a property on the psr_log service that may not exist. If the service is swapped out there is no reason the replacement should have this property. --- CRM/Core/Error/Log.php | 9 ++++++++- Civi/API/LogObserver.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Error/Log.php b/CRM/Core/Error/Log.php index de619aaee0..9904045ad1 100644 --- a/CRM/Core/Error/Log.php +++ b/CRM/Core/Error/Log.php @@ -26,7 +26,14 @@ class CRM_Core_Error_Log extends \Psr\Log\AbstractLogger { * CRM_Core_Error_Log constructor. */ public function __construct() { - $this->map = [ + $this->map = self::getMap(); + } + + /** + * @return array + */ + public static function getMap():array { + return [ \Psr\Log\LogLevel::DEBUG => PEAR_LOG_DEBUG, \Psr\Log\LogLevel::INFO => PEAR_LOG_INFO, \Psr\Log\LogLevel::NOTICE => PEAR_LOG_NOTICE, diff --git a/Civi/API/LogObserver.php b/Civi/API/LogObserver.php index b92eaa67d4..c7cf5a3236 100644 --- a/Civi/API/LogObserver.php +++ b/Civi/API/LogObserver.php @@ -23,7 +23,7 @@ class LogObserver extends \Log_observer { * @param array $event */ public function notify($event) { - $levels = \Civi::log()->map; + $levels = \CRM_Core_Error_Log::getMap(); $event['level'] = array_search($event['priority'], $levels); // Extract [civi.tag] from message string // As noted in \CRM_Core_Error_Log::log() the $context array gets prematurely converted to string with print_r() so we have to un-flatten it here -- 2.25.1