From 847b4937724672b94acf2376ec5df96976f6be2d Mon Sep 17 00:00:00 2001 From: ztimson Date: Wed, 16 Oct 2024 19:55:35 -0400 Subject: [PATCH] Handle logging objects --- package.json | 2 +- src/logger.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 26c3724..9f6fd99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/utils", - "version": "0.20.8", + "version": "0.20.9", "description": "Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/logger.ts b/src/logger.ts index bb4def3..1eaa54c 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1,4 +1,5 @@ import {TypedEmitter, TypedEvents} from './emitter'; +import {JSONSanitize} from './objects.ts'; export const CliEffects = { CLEAR: "\x1b[0m", @@ -75,7 +76,7 @@ export class Logger extends TypedEmitter { private format(...text: string[]): 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.join(' ')}`; + return `${timestamp}${this.namespace ? ` [${this.namespace}]` : ''} ${text.map(JSONSanitize).join(' ')}`; } debug(...args: string[]) {