Comparing version 1.0.5 to 1.1.0
{ | ||
"name": "pino", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "fast and simple logger", | ||
@@ -5,0 +5,0 @@ "main": "pino.js", |
13
pino.js
@@ -156,3 +156,3 @@ 'use strict' | ||
function child (bindings) { | ||
if (!opts) { | ||
if (!bindings) { | ||
throw new Error('missing bindings for child logger') | ||
@@ -213,2 +213,10 @@ } | ||
function asErrValue (err) { | ||
return { | ||
type: err.constructor.name, | ||
message: err.message, | ||
stack: err.stack | ||
} | ||
} | ||
module.exports = pino | ||
@@ -218,3 +226,4 @@ | ||
req: asReqValue, | ||
res: asResValue | ||
res: asResValue, | ||
err: asErrValue | ||
} |
@@ -138,2 +138,3 @@ # pino | ||
* <a href="#resSerializer"><code>pino.stdSerializers.<b>res</b></code></a> | ||
* <a href="#errSerializer"><code>pino.stdSerializers.<b>err</b></code></a> | ||
@@ -328,2 +329,20 @@ <a name="constructor"></a> | ||
<a name="errSerializer"></a> | ||
### pino.stdSerializers.err | ||
Serializes an `Error` object if passed in as an property. | ||
```js | ||
{ | ||
"pid": 40510, | ||
"hostname": "MBP-di-Matteo", | ||
"level": 50, | ||
"msg": "an error", | ||
"time": 1459433282301, | ||
"v": 1, | ||
"type": "Error", | ||
"stack": "Error: an error\n at Object.<anonymous> (/Users/matteo/Repositories/pino/example.js:16:7)\n at Module._compile (module.js:435:26)\n at Object.Module._extensions..js (module.js:442:10)\n at Module.load (module.js:356:32)\n at Function.Module._load (module.js:313:12)\n at Function.Module.runMain (module.js:467:10)\n at startup (node.js:136:18)\n at node.js:963:3" | ||
} | ||
``` | ||
<a name="rotate"></a> | ||
@@ -391,2 +410,9 @@ ## How do I rotate log files | ||
### v1.1.0 | ||
* [#18](https://github.com/mcollina/pino/pull/18) Added the error | ||
serializer | ||
* [#17](https://github.com/mcollina/pino/pull/17) throw when creating a | ||
child logger without bindings | ||
### v1.0.5 | ||
@@ -393,0 +419,0 @@ |
42
test.js
@@ -110,2 +110,30 @@ 'use strict' | ||
test('passing error with a serializer at level ' + name, function (t) { | ||
t.plan(2) | ||
var err = new Error('myerror') | ||
var instance = pino({ | ||
serializers: { | ||
err: pino.stdSerializers.err | ||
} | ||
}, 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, | ||
err: { | ||
type: 'Error', | ||
message: err.message, | ||
stack: err.stack | ||
}, | ||
v: 1 | ||
}) | ||
cb() | ||
})) | ||
instance.level = name | ||
instance[name]({ err: err }) | ||
}) | ||
test('child logger for level ' + name, function (t) { | ||
@@ -484,1 +512,15 @@ t.plan(2) | ||
}) | ||
test('throw if creating child without bindings', function (t) { | ||
t.plan(1) | ||
var instance = pino( | ||
sink(function (chunk, enc, cb) { | ||
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()') | ||
t.end() | ||
})) | ||
t.throws(function () { | ||
instance.child() | ||
}) | ||
}) |
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
443623
1088
448