Comparing version 0.1.2 to 0.2.0
@@ -11,2 +11,5 @@ 'use strict' | ||
info({ obj: 42 }, 'hello world') | ||
info({ obj: 42, b: 2 }, 'hello world') | ||
info({ obj: { aa: 'bbb' } }, 'another') | ||
setImmediate(info, 'after setImmediate') | ||
error(new Error('an error')) |
{ | ||
"name": "pino", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "your logger, inspired by bunyan", | ||
"main": "pino.js", | ||
"bin": { | ||
"pino": "./bin.js" | ||
}, | ||
"scripts": { | ||
@@ -36,2 +39,5 @@ "test": "standard && tap test.js" | ||
"dependencies": { | ||
"chalk": "^1.1.1", | ||
"core-util-is": "^1.0.2", | ||
"fast-json-parse": "^1.0.0", | ||
"json-stringify-safe": "^5.0.1", | ||
@@ -38,0 +44,0 @@ "split2": "^2.0.1" |
14
pino.js
@@ -87,9 +87,17 @@ 'use strict' | ||
function asJson (obj, msg, num) { // eslint-disable-line no-unused-vars | ||
if (!msg && obj instanceof Error) { | ||
msg = obj.message | ||
} | ||
var data = JSON.stringify(new Message(num, msg)) | ||
if (obj) { | ||
data = data.slice(0, data.length - 1) | ||
for (var key in obj) { | ||
data += ',"' + key + '":' + stringify(obj[key]) | ||
if (obj instanceof Error) { | ||
data += ',"type":"Error","stack":' + stringify(obj.stack) + '}' | ||
} else { | ||
for (var key in obj) { | ||
data += ',"' + key + '":' + stringify(obj[key]) | ||
} | ||
data += '}' | ||
} | ||
data += '}' | ||
} | ||
@@ -96,0 +104,0 @@ return data + '\n' |
# pino | ||
[Extremely fast](#benchmarks) node.js logger, inspired by Bunyan. | ||
It also includes a shell utility to pretty-print its log files. | ||
![cli](https://raw.githubusercontent.com/mcollina/pino/master/demo.png) | ||
Still _alpha code_, and in active development. | ||
@@ -24,2 +27,3 @@ | ||
var info = pino.info | ||
var error = pino.error | ||
@@ -30,2 +34,3 @@ info('hello world') | ||
setImmediate(info, 'wrapped') | ||
error(new Error('something bad happened')) | ||
``` | ||
@@ -32,0 +37,0 @@ |
22
test.js
@@ -86,2 +86,24 @@ 'use strict' | ||
}) | ||
test('passing error at level ' + name, function (t) { | ||
t.plan(2) | ||
var err = new Error('myerror') | ||
var instance = pino(sink(function (chunk, enc, cb) { | ||
t.ok(Date.parse(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, | ||
v: 0 | ||
}) | ||
cb() | ||
})) | ||
instance.level = name | ||
instance[name](err) | ||
}) | ||
} | ||
@@ -88,0 +110,0 @@ |
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
228373
11
411
62
5
+ Addedchalk@^1.1.1
+ Addedcore-util-is@^1.0.2
+ Addedfast-json-parse@^1.0.0
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfast-json-parse@1.0.3(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)