Skip to content

Commit

Permalink
Add test for brighterscript logging format
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed May 9, 2024
1 parent 6666c97 commit 3a73ac9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Logger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
8 changes: 5 additions & 3 deletions src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
/**
Expand Down

0 comments on commit 3a73ac9

Please sign in to comment.