From 5ec0e5b135b6c1c24cada7ac2e10dafb219e503a Mon Sep 17 00:00:00 2001 From: hamzashaikhcan Date: Tue, 21 Dec 2021 21:15:58 +0500 Subject: [PATCH 1/5] Added JSON Parsing (If Available) --- lib/bunyan.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bunyan.js b/lib/bunyan.js index 405cdb24..9cd4305a 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -238,7 +238,12 @@ var _warned = {}; function ConsoleRawStream() {} ConsoleRawStream.prototype.write = function (rec) { if (rec.level < INFO) { - console.log(rec); + try { + rec = JSON.parse(x); + console.log(rec); + } catch (e) { + console.log(rec); + } } else if (rec.level < WARN) { console.info(rec); } else if (rec.level < ERROR) { From 1bb8a6b3671b0d6e5f3141897ecdedd965e00564 Mon Sep 17 00:00:00 2001 From: hamzashaikhcan Date: Tue, 21 Dec 2021 21:23:08 +0500 Subject: [PATCH 2/5] Added JSON Parsing (If Available) --- lib/bunyan.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bunyan.js b/lib/bunyan.js index 9cd4305a..caa96195 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -240,7 +240,7 @@ ConsoleRawStream.prototype.write = function (rec) { if (rec.level < INFO) { try { rec = JSON.parse(x); - console.log(rec); + console.log(rec); } catch (e) { console.log(rec); } From 8317639e7e032fbe8cd275600d0c8334a4c8d29f Mon Sep 17 00:00:00 2001 From: hamzashaikhcan Date: Tue, 21 Dec 2021 21:24:27 +0500 Subject: [PATCH 3/5] Added JSON Parsing (If Available) --- lib/bunyan.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bunyan.js b/lib/bunyan.js index caa96195..9cd4305a 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -240,7 +240,7 @@ ConsoleRawStream.prototype.write = function (rec) { if (rec.level < INFO) { try { rec = JSON.parse(x); - console.log(rec); + console.log(rec); } catch (e) { console.log(rec); } From 745f36797a29452e37b628f8ff9d7b0d97778e42 Mon Sep 17 00:00:00 2001 From: hamzashaikhcan Date: Tue, 21 Dec 2021 21:41:00 +0500 Subject: [PATCH 4/5] Fixed JSON Parsing Issue --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index fff33b2e..639b1e11 100644 --- a/AUTHORS +++ b/AUTHORS @@ -40,3 +40,4 @@ Frankie O'Rourke (https://github.com/psfrankie) Cody Mello (https://github.com/melloc) Todd Whiteman (https://github.com/twhiteman) Zach Bjornson (https://github.com/zbjornson) +Hamza Shaikh (https://github.com/hamzashaikhcan) From 613e008f718de38884ca966ea58dfd9ed5b3ec36 Mon Sep 17 00:00:00 2001 From: hamzashaikhcan Date: Tue, 21 Dec 2021 21:42:38 +0500 Subject: [PATCH 5/5] Fixed JSON Parsing Issue --- lib/bunyan.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/bunyan.js b/lib/bunyan.js index 9cd4305a..6fcbf36a 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -239,10 +239,10 @@ function ConsoleRawStream() {} ConsoleRawStream.prototype.write = function (rec) { if (rec.level < INFO) { try { - rec = JSON.parse(x); - console.log(rec); + rec = JSON.parse(x); // Convert string to JSON + console.log(rec); // Log JSON Data } catch (e) { - console.log(rec); + console.log(rec); // Log simple string } } else if (rec.level < WARN) { console.info(rec);