From 1bca0bbfb97b65981048c3adc835ebaa06a8b231 Mon Sep 17 00:00:00 2001 From: Jacopo Daeli Date: Fri, 28 May 2021 13:50:06 -0400 Subject: [PATCH] fix(getTransformStream): compare `opts.logLevelInString` as boolean (#116) --- index.js | 2 +- test/index.test.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 037ed58..86dd4d0 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,7 @@ const LEVEL_MAP = { function getTransformStream(options = {}) { const formattingEnabled = options.logFormat !== "json"; - const levelAsString = options.logLevelInString === "true"; + const levelAsString = options.logLevelInString; const sentryEnabled = !!options.sentryDsn; if (sentryEnabled) { diff --git a/test/index.test.js b/test/index.test.js index f702eed..dd9cdac 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -143,6 +143,7 @@ test("API", (t) => { const transform = getTransformStream({ logFormat: "json", + logLevelInString: true, }); transform.pipe(streamLogsToOutput); const log = pino({}, transform); @@ -155,6 +156,8 @@ test("API", (t) => { 'No "\\n" is added to end of line' ); + t.equal(JSON.parse(output).level, "info"); + t.end(); } );