From ee6714b568939cb264bc3a7a99fec7f372d95586 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 28 Aug 2012 10:40:58 -0700 Subject: [PATCH] [issue #38] Fix the default `bunyan` CLI output of a `req.body` that is an object instead of a string. --- CHANGES.md | 3 ++- bin/bunyan | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7219eae..5b0b834 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,8 @@ ## bunyan 0.13.4 (not yet released) -(nothing yet) +- [issue #38] Fix the default `bunyan` CLI output of a `req.body` that is an + object instead of a string. ## bunyan 0.13.3 diff --git a/bin/bunyan b/bin/bunyan index 5393929..ed7e045 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -628,7 +628,8 @@ function emitRecord(rec, line, opts, stylize) { delete req.httpVersion; delete req.headers; if (req.body) { - s += '\n\n' + req.body; + s += '\n\n' + (typeof(req.body) === 'object' + ? JSON.stringify(req.body, null, 2) : req.body); delete req.body; } if (req.trailers && Object.keys(req.trailers) > 0) { @@ -669,7 +670,8 @@ function emitRecord(rec, line, opts, stylize) { delete client_req.url; delete client_req.httpVersion; if (client_req.body) { - s += '\n\n' + client_req.body + s += '\n\n' + (typeof(client_req.body) === 'object' + ? JSON.stringify(client_req.body, null, 2) : client_req.body); delete client_req.body; } // E.g. for extra 'foo' field on 'client_req', add 'client_req.foo' at