1
0
Fork 0

[DEV-5312] Use formatted time when logging events

master
Austin Schaffer 2019-12-17 11:46:34 -05:00
parent 542745da8a
commit 699ee29a95
3 changed files with 8 additions and 5 deletions

View File

@ -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 = <StructuredLog>{
message: str,
timestamp: this._ts_ctr(),
timestamp: tsFormatted,
service: 'quote-server',
env: this._env,
severity: LogLevel[level],

View File

@ -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', () =>
{

View File

@ -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',