Comparing version 3.1.3 to 3.2.0
{ | ||
"name": "pino", | ||
"version": "3.1.3", | ||
"version": "3.2.0", | ||
"description": "super fast, all natural json logger", | ||
@@ -5,0 +5,0 @@ "main": "pino.js", |
21
pino.js
@@ -51,4 +51,4 @@ 'use strict' | ||
}) | ||
Object.defineProperty(onObject.levels.values, 'silent', {value: 100}) | ||
Object.defineProperty(onObject.levels.labels, '100', {value: 'silent'}) | ||
Object.defineProperty(onObject.levels.values, 'silent', {value: Infinity}) | ||
Object.defineProperty(onObject.levels.labels, Infinity, {value: 'silent'}) | ||
} | ||
@@ -60,2 +60,5 @@ | ||
return function (level) { | ||
if (Infinity === level) { | ||
return true | ||
} | ||
return keys.indexOf(level) > -1 | ||
@@ -68,2 +71,5 @@ } | ||
return function (val) { | ||
if (!isFinite(val)) { | ||
return true | ||
} | ||
return keys.indexOf(val + '') > -1 | ||
@@ -217,6 +223,11 @@ } | ||
Pino.prototype._setLevel = function _setLevel (level) { | ||
if (typeof level === 'number') { level = this.levels.labels[level] } | ||
if (typeof level === 'number') { | ||
if (!isFinite(level)) { | ||
throw Error('unknown level ' + level) | ||
} | ||
level = this.levels.labels[level] | ||
} | ||
if (!this.levels.values[level]) { | ||
throw new Error('unknown level ' + level) | ||
throw Error('unknown level ' + level) | ||
} | ||
@@ -425,3 +436,3 @@ this.levelVal = this.levels.values[level] | ||
m = mapHttpRequest(m) | ||
} else if (m.statusCode) { | ||
} else if (typeof m.setHeader === 'function') { | ||
m = mapHttpResponse(m) | ||
@@ -428,0 +439,0 @@ } |
@@ -116,2 +116,9 @@ 'use strict' | ||
test('reject values of Infinity', function (t) { | ||
t.plan(1) | ||
t.throws(function () { | ||
pino({level: 'foo', levelVal: Infinity}) | ||
}, /.*level value is already used.*/) | ||
}) | ||
test('level numbers are logged correctly after level change', function (t) { | ||
@@ -118,0 +125,0 @@ t.plan(1) |
@@ -108,1 +108,24 @@ 'use strict' | ||
}) | ||
test('an error with statusCode property is not confused for a http response', function (t) { | ||
t.plan(2) | ||
var err = Object.assign(new Error('StatusCodeErr'), { statusCode: 500 }) | ||
var instance = pino(sink(function (chunk, enc, cb) { | ||
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()') | ||
delete chunk.time | ||
t.deepEqual(chunk, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
type: 'Error', | ||
msg: err.message, | ||
stack: err.stack, | ||
statusCode: err.statusCode, | ||
v: 1 | ||
}) | ||
cb() | ||
})) | ||
instance.level = name | ||
instance[name](err) | ||
}) |
@@ -149,15 +149,2 @@ 'use strict' | ||
test('setting level to 100', function (t) { | ||
var instance = pino({ | ||
level: 100 | ||
}, sink(function (chunk, enc, cb) { | ||
t.fail('no data should be logged') | ||
})) | ||
Object.keys(pino.levels.values).forEach(function (level) { | ||
instance[level]('hello world') | ||
}) | ||
t.end() | ||
}) | ||
test('exposed levels', function (t) { | ||
@@ -164,0 +151,0 @@ t.plan(1) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104858
2379