From 2474b5c6218cadbc2b1f2162a21bde3852714aee Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Fri, 5 Jan 2024 10:40:55 +0000 Subject: [PATCH 1/2] Fix console.log(JSON) fixes #218 --- lib/logging/log.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/logging/log.js b/lib/logging/log.js index 1ff3892..5b1338d 100644 --- a/lib/logging/log.js +++ b/lib/logging/log.js @@ -24,6 +24,10 @@ function NRlog (msg) { } catch (eee) { jsMsg = { ts: Date.now(), level: '', msg } } + if (!jsMsg.hasOwnProperty('ts') && !jsMsg.hasOwnProperty('level')) { + // not a NR log message + jsMsg = { ts: Date.now(), level: '', msg } + } const date = new Date(jsMsg.ts) if (typeof jsMsg.msg !== 'string') { jsMsg.msg = JSON.stringify(jsMsg.msg) From 8b1e64d0a851c3f0efbd6e565a6ecfd196541bfc Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Fri, 5 Jan 2024 10:55:40 +0000 Subject: [PATCH 2/2] fix lint --- lib/logging/log.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logging/log.js b/lib/logging/log.js index 5b1338d..92d4cda 100644 --- a/lib/logging/log.js +++ b/lib/logging/log.js @@ -24,7 +24,7 @@ function NRlog (msg) { } catch (eee) { jsMsg = { ts: Date.now(), level: '', msg } } - if (!jsMsg.hasOwnProperty('ts') && !jsMsg.hasOwnProperty('level')) { + if (!Object.hasOwn(jsMsg, 'ts') && !Object.hasOwn(jsMsg, 'level')) { // not a NR log message jsMsg = { ts: Date.now(), level: '', msg } }