From 89e276a336182d036795ff775bb4b8e407daaf9e Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Wed, 15 Jul 2026 19:18:38 -0700 Subject: [PATCH] Store logger locale info instead of calling on every log. --- src/utils/logger.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/logger.ts b/src/utils/logger.ts index bf63b87..5f24ecf 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -8,6 +8,12 @@ export class Logger { #groups: Record = {} #isEnabled: boolean = false + #locale: string = Intl.DateTimeFormat().resolvedOptions().locale ?? 'en-US' + #localeOptions: Intl.DateTimeFormatOptions = { + hour12: false, + dateStyle: 'medium', + timeStyle: 'medium' + } #noop (...args: any[]): void { } #groupStart (name: string): void { @@ -23,7 +29,7 @@ export class Logger { } #log (...args: any[]): void { - const datetime = new Date(Date.now()).toLocaleString(Intl.DateTimeFormat().resolvedOptions().locale ?? 'en-US', { hour12: false, dateStyle: 'medium', timeStyle: 'medium' }) + const datetime = new Date(Date.now()).toLocaleString(this.#locale, this.#localeOptions) for (let i = 0; i < args.length; i++) { if (typeof args[i] === 'string') { args[i] = args[i].replace(datetime, '').trimStart() -- 2.52.0