From 854f3c193b4c2b5fc9bd5a15bef3697c187d1f8b Mon Sep 17 00:00:00 2001 From: Toby Li Date: Wed, 19 Dec 2018 15:21:28 +0000 Subject: [PATCH 1/4] Added css property to ConsoleFormattedStreamOptions --- types/browser-bunyan/index.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/types/browser-bunyan/index.d.ts b/types/browser-bunyan/index.d.ts index 4fedbcd780..0057294174 100644 --- a/types/browser-bunyan/index.d.ts +++ b/types/browser-bunyan/index.d.ts @@ -10,8 +10,25 @@ import * as bunyan from 'bunyan'; declare namespace BrowserBunyan { + interface ConsoleFormattedStreamLevelStyle { + trace: string; + debug: string; + info: string; + warn: string; + error: string; + fatal: string; + } + + interface ConsoleFormattedStreamStyle { + levels: Partial; + def: string; + msg: string; + src: string; + } + interface ConsoleFormattedStreamOptions { logByLevel?: boolean; + css?: Partial; } interface ConsoleFormattedStream { From db87a2eef525a4ec7161fe3b4c94575aecbc1b31 Mon Sep 17 00:00:00 2001 From: Toby Li Date: Wed, 19 Dec 2018 16:30:25 +0000 Subject: [PATCH 2/4] change interface to type --- types/browser-bunyan/index.d.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/types/browser-bunyan/index.d.ts b/types/browser-bunyan/index.d.ts index 0057294174..24d4b3e874 100644 --- a/types/browser-bunyan/index.d.ts +++ b/types/browser-bunyan/index.d.ts @@ -31,13 +31,9 @@ declare namespace BrowserBunyan { css?: Partial; } - interface ConsoleFormattedStream { - new(options?: ConsoleFormattedStreamOptions): NodeJS.WritableStream; - } + type ConsoleFormattedStream = new(options?: ConsoleFormattedStreamOptions) => NodeJS.WritableStream; - interface ConsoleRawStream { - new(options?: ConsoleFormattedStreamOptions): NodeJS.WritableStream; - } + type ConsoleRawStream = new(options?: ConsoleFormattedStreamOptions) => NodeJS.WritableStream; } type BrowserBunyan = typeof bunyan & { From 13f7aabdbe337ef4e86f073ea7d6c885db2bf66b Mon Sep 17 00:00:00 2001 From: Toby Li Date: Wed, 19 Dec 2018 17:00:43 +0000 Subject: [PATCH 3/4] added test for css property --- types/browser-bunyan/browser-bunyan-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/types/browser-bunyan/browser-bunyan-tests.ts b/types/browser-bunyan/browser-bunyan-tests.ts index 6cf1bf926b..82b5831ef8 100644 --- a/types/browser-bunyan/browser-bunyan-tests.ts +++ b/types/browser-bunyan/browser-bunyan-tests.ts @@ -23,3 +23,19 @@ const myObject = { x: 1, y: 2 }; log.info({ obj: myObject }, 'This is my object:'); new bunyan.ConsoleFormattedStream({ logByLevel: true }); + +const style = { + levels : { + trace: 'color: DeepPink', + debug: 'color: GoldenRod', + info: 'color: DarkTurquoise', + warm: 'color: Purple', + error: 'color: Crimson', + fatal: 'color: Black', + }, + def: 'color: DimGray', + msg : 'color: SteelBlue', + src : 'color: DimGray; font-style: italic; font-size: 0.9em', +}; + +new bunyan.ConsoleFormattedStream({ css: style }); From 7c977f0285b4de977f624ebe38873b79c4dea23c Mon Sep 17 00:00:00 2001 From: Toby Li Date: Wed, 19 Dec 2018 17:32:12 +0000 Subject: [PATCH 4/4] fix typo --- types/browser-bunyan/browser-bunyan-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/browser-bunyan/browser-bunyan-tests.ts b/types/browser-bunyan/browser-bunyan-tests.ts index 82b5831ef8..9dcb519c27 100644 --- a/types/browser-bunyan/browser-bunyan-tests.ts +++ b/types/browser-bunyan/browser-bunyan-tests.ts @@ -25,17 +25,17 @@ log.info({ obj: myObject }, 'This is my object:'); new bunyan.ConsoleFormattedStream({ logByLevel: true }); const style = { - levels : { + levels: { trace: 'color: DeepPink', debug: 'color: GoldenRod', info: 'color: DarkTurquoise', - warm: 'color: Purple', + warn: 'color: Purple', error: 'color: Crimson', fatal: 'color: Black', }, def: 'color: DimGray', - msg : 'color: SteelBlue', - src : 'color: DimGray; font-style: italic; font-size: 0.9em', + msg: 'color: SteelBlue', + src: 'color: DimGray; font-style: italic; font-size: 0.9em', }; new bunyan.ConsoleFormattedStream({ css: style });