From 3a73ac957b2d92c4c5dcd675afd2140f3a9a958b Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Thu, 9 May 2024 15:06:47 -0400 Subject: [PATCH] Add test for brighterscript logging format --- src/Logger.spec.ts | 5 +++++ src/Logger.ts | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Logger.spec.ts b/src/Logger.spec.ts index 5858774..40df4ed 100644 --- a/src/Logger.spec.ts +++ b/src/Logger.spec.ts @@ -293,6 +293,11 @@ describe('Logger', () => { logger.formatTimestamp(now) ).to.eql(timestamp); }); + + it('supports the brighterscript log format', () => { + logger.timestampFormat = 'hh:mm:ss:SSS aa'; + expect(logger.formatTimestamp(now)).to.eql('04:05:06:789 AM'); + }); }); describe('emit', () => { diff --git a/src/Logger.ts b/src/Logger.ts index c92d08e..a523cfc 100644 --- a/src/Logger.ts +++ b/src/Logger.ts @@ -22,7 +22,9 @@ export class Logger { private options: LoggerOptions; /** - * The format used for timestamp. Defaults to 'HH:mm:ss.SSS' (24-hour time with milliseconds) + * The timestamp format string. Defaults to 'HH:mm:ss.SSS' (24-hour time with milliseconds) + * + * https://date-fns.org/v2.30.0/docs/format */ public get timestampFormat(): string { return this.options.timestampFormat ?? this.options.parent?.timestampFormat ?? 'HH:mm:ss.SSS'; @@ -476,9 +478,9 @@ export type LogLevel = 'off' | 'error' | 'warn' | 'log' | 'info' | 'debug' | 'tr export interface LoggerOptions { /** - * Format string for the timestamp. Defaults to 'HH:mm:ss.SSS' (24-hour time with milliseconds) + * The timestamp format string. Defaults to 'HH:mm:ss.SSS' (24-hour time with milliseconds) * - * https://date-fns.org/v3.6.0/docs/format + * https://date-fns.org/v2.30.0/docs/format */ timestampFormat?: string; /**