diff --git a/CHANGES.md b/CHANGES.md index 75c91fd..cbc0253 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,8 @@ Known issues: ## bunyan 1.3.5 (not yet released) -- [issue #242] Be defensive on err.stack not being a string. +- [issue #233] Make `bunyan` defensive on res.header as a boolean. +- [issue #242] Make `bunyan` defensive on err.stack not being a string. ## bunyan 1.3.4 diff --git a/bin/bunyan b/bin/bunyan index e4e387b..096db52 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -927,15 +927,18 @@ function emitRecord(rec, line, opts, stylize) { // and object of header key/value pairs. Prefer `res.header` if set // (TODO: Why? I don't recall. Typical of restify serializer? // Typical JSON.stringify of a core node HttpResponse?) + var headerTypes = {string: true, object: true}; var headers; - if (res.header !== undefined) { + if (res.header !== undefined && headerTypes[typeof (res.header)]) { headers = res.header; delete res.header; - } else if (res.headers !== undefined) { + } else if (res.headers !== undefined && + headerTypes[typeof (res.headers)]) + { headers = res.headers; delete res.headers; } - if (!headers) { + if (headers === undefined) { /* pass through */ } else if (typeof (headers) === 'string') { s += headers.trimRight();