From a4a5b18849dbc7fca3f98383a183bbc0e2db8add Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 11 Jun 2020 14:28:03 +0000 Subject: [PATCH] fix(core): update --- test/test.ts | 1 + ts/smartlog.classes.smartlog.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/test.ts b/test/test.ts index e84afd3..f058907 100644 --- a/test/test.ts +++ b/test/test.ts @@ -42,6 +42,7 @@ tap.test('should create a log group', async () => { tap.test('should catch error', async () => { console.error(new Error('hey')); + // throw new Error('hey'); }); tap.start(); diff --git a/ts/smartlog.classes.smartlog.ts b/ts/smartlog.classes.smartlog.ts index 311754e..0d01cb5 100644 --- a/ts/smartlog.classes.smartlog.ts +++ b/ts/smartlog.classes.smartlog.ts @@ -42,8 +42,15 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination { flags: 'a+' }); */ process.stdout.write = (...args) => { - if (!args[0].startsWith('LOG')) { - this.log('info', args[0]); + const logString = args[0]; + if (!logString.startsWith('LOG')) { + switch(true) { + case logString.startsWith('Error:'): + this.log('error', logString); + break; + default: + this.log('info', logString); + } return; } // fileStream.write(args[0]);