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.
*/
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;
}
/**