From 8c2545f824a72f720c7bcee8d48a240b9f42e678 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 21 Jul 2023 01:33:27 -0700 Subject: [PATCH] Civi::log() - Show errors via session status-message (under right conditions) 1. The priority is 'error' (or something more severe) 2. The site has enabled debug output 3. The page-request message occurs while the session is available --- CRM/Core/Error/Log.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Error/Log.php b/CRM/Core/Error/Log.php index 964c7ed0ac..59bd871b7f 100644 --- a/CRM/Core/Error/Log.php +++ b/CRM/Core/Error/Log.php @@ -59,9 +59,17 @@ class CRM_Core_Error_Log extends \Psr\Log\AbstractLogger { if (isset($context['exception'])) { $context['exception'] = CRM_Core_Error::formatTextException($context['exception']); } - $message .= "\n" . print_r($context, 1); + $fullContext = "\n" . print_r($context, 1); + $seeLog = sprintf(' (%s)', ts('See log for details.')); + } + else { + $fullContext = $seeLog = ''; + } + $pearPriority = $this->map[$level]; + CRM_Core_Error::debug_log_message($message . $fullContext, FALSE, '', $pearPriority); + if ($pearPriority <= PEAR_LOG_ERR && CRM_Core_Config::singleton()->debug && isset($_SESSION['CiviCRM'])) { + CRM_Core_Session::setStatus($message . $seeLog, ts('Error'), 'error'); } - CRM_Core_Error::debug_log_message($message, FALSE, '', $this->map[$level]); } } -- 2.25.1