From 0888d7bdba5a4d479084fc5fbc9045da31ab5a1a Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 1 Nov 2023 12:57:52 -0700 Subject: [PATCH] Logging - If valid, then set a locale This is an updated variation of Seamus's 27974, with two key differences: 1. It calls `setLocale()` one time -- from within `createDebugLogger()`. (This becomes an internal detail of how `createDebugLogger()` works.) 2. It calls `setLocale()` conditionally -- if the method actually exists. It's not certain whether the method will ultimately be part of the official `pear/log` releases. (*And once upstream changes, it may immediately affect D9/D10-style builds.*) This change means that civicrm-core should with `pear/log` in either contingency. --- CRM/Core/Error.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index bdc6e6d03e..28dac3a85d 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -655,9 +655,13 @@ class CRM_Core_Error extends PEAR_ErrorStack { */ public static function createDebugLogger($prefix = '') { self::generateLogFileName($prefix); - return Log::singleton('file', \Civi::$statics[__CLASS__]['logger_file' . $prefix], '', [ + $log = Log::singleton('file', \Civi::$statics[__CLASS__]['logger_file' . $prefix], '', [ 'timeFormat' => '%Y-%m-%d %H:%M:%S%z', ]); + if (is_callable([$log, 'setLocale'])) { + $log->setLocale(CRM_Core_I18n::getLocale()); + } + return $log; } /** -- 2.25.1