From cebfd2c508548829cc36061c437b48b6161cabc9 Mon Sep 17 00:00:00 2001 From: ztimson Date: Wed, 16 Oct 2024 20:28:56 -0400 Subject: [PATCH] Object logging with formatting --- package.json | 2 +- src/logger.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a82c2d1..a5f9064 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/utils", - "version": "0.20.10", + "version": "0.20.11", "description": "Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/logger.ts b/src/logger.ts index 15ac761..93472ea 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -76,7 +76,7 @@ export class Logger extends TypedEmitter { private format(...text: any[]): string { const now = new Date(); const timestamp = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()} ${this.pad(now.getHours().toString(), 2, '0')}:${this.pad(now.getMinutes().toString(), 2, '0')}:${this.pad(now.getSeconds().toString(), 2, '0')}.${this.pad(now.getMilliseconds().toString(), 3, '0', true)}`; - return `${timestamp}${this.namespace ? ` [${this.namespace}]` : ''} ${text.map(JSONSanitize).join(' ')}`; + return `${timestamp}${this.namespace ? ` [${this.namespace}]` : ''} ${text.map(t => typeof t == 'string' ? t : JSONSanitize(t, 2)).join(' ')}`; } debug(...args: any[]) {