From ec3be9fc948bf7f2eb3913c449aca82eef7c5793 Mon Sep 17 00:00:00 2001 From: Mark Cavage Date: Thu, 4 Apr 2013 23:57:17 +0000 Subject: [PATCH] rework so that res and client_res can coexist --- bin/bunyan | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/bunyan b/bin/bunyan index 15ccf37..ba176bb 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -830,13 +830,7 @@ function emitRecord(rec, line, opts, stylize) { details.push(indent(s)); } - if ((rec.res && typeof (rec.res) === 'object') || - (rec.client_res && typeof (rec.client_res) === 'object')) { - var res = rec.res || rec.client_res; - if (rec.res) - delete rec.res; - if (rec.client_res) - delete rec.client_res; + function _res(res) { var s = ''; if (res.header) { s += res.header.trimRight(); @@ -872,6 +866,15 @@ function emitRecord(rec, line, opts, stylize) { }); } + if (rec.res && typeof (rec.res) === 'object') { + _res(rec.res); + delete rec.res; + } + if (rec.client_res && typeof (rec.client_res) === 'object') { + _res(rec.client_res); + delete rec.res; + } + if (rec.err && rec.err.stack) { details.push(indent(rec.err.stack)); delete rec.err;