From 699ee29a953b9b509979a503e70ae3a5fcf7ace7 Mon Sep 17 00:00:00 2001 From: Austin Schaffer Date: Tue, 17 Dec 2019 11:46:34 -0500 Subject: [PATCH] [DEV-5312] Use formatted time when logging events --- src/system/StandardLogger.ts | 7 +++++-- test/system/EventMediatorTest.ts | 2 +- test/system/StandardLoggerTest.ts | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/system/StandardLogger.ts b/src/system/StandardLogger.ts index cdd062d..7bf762d 100644 --- a/src/system/StandardLogger.ts +++ b/src/system/StandardLogger.ts @@ -24,7 +24,7 @@ import { PsrLogger, LogLevel } from './PsrLogger'; declare type StructuredLog = { message: string; - timestamp: UnixTimestamp; + timestamp: string; service: string; env: string; severity: string; @@ -181,9 +181,12 @@ export class StandardLogger implements PsrLogger str = msg; } + const ts = this._ts_ctr(); + const tsFormatted = new Date( ts * 1000 ).toISOString() + const structured_log = { message: str, - timestamp: this._ts_ctr(), + timestamp: tsFormatted, service: 'quote-server', env: this._env, severity: LogLevel[level], diff --git a/test/system/EventMediatorTest.ts b/test/system/EventMediatorTest.ts index abfbef8..cf854b6 100644 --- a/test/system/EventMediatorTest.ts +++ b/test/system/EventMediatorTest.ts @@ -26,7 +26,7 @@ import { expect } from 'chai'; import { PsrLogger } from '../../src/system/PsrLogger'; -describe( 'system.EventLogger captures and logs events', () => +describe( 'system.EventMediator captures and logs events', () => { it( 'document-processed triggers log#notice', () => { diff --git a/test/system/StandardLoggerTest.ts b/test/system/StandardLoggerTest.ts index 918bfd1..d655e0b 100644 --- a/test/system/StandardLoggerTest.ts +++ b/test/system/StandardLoggerTest.ts @@ -30,7 +30,7 @@ declare interface MockConsole extends Console { getStr(): string, } -describe( 'system.EventLogger captures and logs events', () => +describe( 'system.StandardLogger captures and logs events', () => { it( 'debug triggers console output level: info', () => { @@ -139,7 +139,7 @@ describe( 'system.EventLogger captures and logs events', () => const context = { bar: 'baz' }; const expected_output = { message: 'Foo', - timestamp: 123123, + timestamp: '1970-01-02T10:12:03.000Z', service: 'quote-server', env: 'test', severity: 'NOTICE',