[DEV-5312] Use formatted time when logging events
parent
542745da8a
commit
699ee29a95
|
@ -24,7 +24,7 @@ import { PsrLogger, LogLevel } from './PsrLogger';
|
||||||
|
|
||||||
declare type StructuredLog = {
|
declare type StructuredLog = {
|
||||||
message: string;
|
message: string;
|
||||||
timestamp: UnixTimestamp;
|
timestamp: string;
|
||||||
service: string;
|
service: string;
|
||||||
env: string;
|
env: string;
|
||||||
severity: string;
|
severity: string;
|
||||||
|
@ -181,9 +181,12 @@ export class StandardLogger implements PsrLogger
|
||||||
str = msg;
|
str = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ts = this._ts_ctr();
|
||||||
|
const tsFormatted = new Date( ts * 1000 ).toISOString()
|
||||||
|
|
||||||
const structured_log = <StructuredLog>{
|
const structured_log = <StructuredLog>{
|
||||||
message: str,
|
message: str,
|
||||||
timestamp: this._ts_ctr(),
|
timestamp: tsFormatted,
|
||||||
service: 'quote-server',
|
service: 'quote-server',
|
||||||
env: this._env,
|
env: this._env,
|
||||||
severity: LogLevel[level],
|
severity: LogLevel[level],
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { expect } from 'chai';
|
||||||
import { PsrLogger } from '../../src/system/PsrLogger';
|
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', () =>
|
it( 'document-processed triggers log#notice', () =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ declare interface MockConsole extends Console {
|
||||||
getStr(): string,
|
getStr(): string,
|
||||||
}
|
}
|
||||||
|
|
||||||
describe( 'system.EventLogger captures and logs events', () =>
|
describe( 'system.StandardLogger captures and logs events', () =>
|
||||||
{
|
{
|
||||||
it( 'debug triggers console output level: info', () =>
|
it( 'debug triggers console output level: info', () =>
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,7 @@ describe( 'system.EventLogger captures and logs events', () =>
|
||||||
const context = { bar: 'baz' };
|
const context = { bar: 'baz' };
|
||||||
const expected_output = {
|
const expected_output = {
|
||||||
message: 'Foo',
|
message: 'Foo',
|
||||||
timestamp: 123123,
|
timestamp: '1970-01-02T10:12:03.000Z',
|
||||||
service: 'quote-server',
|
service: 'quote-server',
|
||||||
env: 'test',
|
env: 'test',
|
||||||
severity: 'NOTICE',
|
severity: 'NOTICE',
|
||||||
|
|
Loading…
Reference in New Issue