Make bunyan
defensive on res.header as a boolean. Fixes #233
This commit is contained in:
parent
24528aa638
commit
d820b03dcd
2 changed files with 8 additions and 4 deletions
|
@ -8,7 +8,8 @@ Known issues:
|
||||||
|
|
||||||
## bunyan 1.3.5 (not yet released)
|
## 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
|
## bunyan 1.3.4
|
||||||
|
|
|
@ -927,15 +927,18 @@ function emitRecord(rec, line, opts, stylize) {
|
||||||
// and object of header key/value pairs. Prefer `res.header` if set
|
// and object of header key/value pairs. Prefer `res.header` if set
|
||||||
// (TODO: Why? I don't recall. Typical of restify serializer?
|
// (TODO: Why? I don't recall. Typical of restify serializer?
|
||||||
// Typical JSON.stringify of a core node HttpResponse?)
|
// Typical JSON.stringify of a core node HttpResponse?)
|
||||||
|
var headerTypes = {string: true, object: true};
|
||||||
var headers;
|
var headers;
|
||||||
if (res.header !== undefined) {
|
if (res.header !== undefined && headerTypes[typeof (res.header)]) {
|
||||||
headers = res.header;
|
headers = res.header;
|
||||||
delete res.header;
|
delete res.header;
|
||||||
} else if (res.headers !== undefined) {
|
} else if (res.headers !== undefined &&
|
||||||
|
headerTypes[typeof (res.headers)])
|
||||||
|
{
|
||||||
headers = res.headers;
|
headers = res.headers;
|
||||||
delete res.headers;
|
delete res.headers;
|
||||||
}
|
}
|
||||||
if (!headers) {
|
if (headers === undefined) {
|
||||||
/* pass through */
|
/* pass through */
|
||||||
} else if (typeof (headers) === 'string') {
|
} else if (typeof (headers) === 'string') {
|
||||||
s += headers.trimRight();
|
s += headers.trimRight();
|
||||||
|
|
Loading…
Reference in a new issue