Skip to content

Commit

Permalink
Civi::log() - Show errors via session status-message (under right con…
Browse files Browse the repository at this point in the history
…ditions)

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
  • Loading branch information
totten committed Jul 21, 2023
1 parent 319166f commit 25ce257
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CRM/Core/Error/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ public function log($level, $message, array $context = []): void {
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('(<em>%s</em>)', 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]);
}

}

0 comments on commit 25ce257

Please sign in to comment.