Comparing version 4.0.3 to 4.1.0
{ | ||
"name": "pino", | ||
"version": "4.0.3", | ||
"version": "4.1.0", | ||
"description": "super fast, all natural json logger", | ||
@@ -8,3 +8,3 @@ "main": "pino.js", | ||
"bin": { | ||
"pino": "./pretty.js" | ||
"pino": "./bin.js" | ||
}, | ||
@@ -23,4 +23,4 @@ "files": [ | ||
"browser-test": "zuul tape test/browser.test.js --local", | ||
"test": "standard && tap --no-cov test/*test.js", | ||
"ci": "standard && tap --cov test/*test.js", | ||
"test": "standard | snazzy && tap --no-cov test/*test.js", | ||
"ci": "standard | snazzy && tap --cov test/*test.js", | ||
"bench-all": "node benchmarks/runbench all", | ||
@@ -70,3 +70,4 @@ "bench-basic": "node benchmarks/runbench basic", | ||
"pump": "^1.0.1", | ||
"standard": "^8.6.0", | ||
"snazzy": "^6.0.0", | ||
"standard": "^9.0.0", | ||
"steed": "^1.1.3", | ||
@@ -73,0 +74,0 @@ "tap": "^10.0.0", |
378
pino.js
@@ -33,85 +33,23 @@ 'use strict' | ||
function pino (opts, stream) { | ||
var iopts = opts | ||
var istream = stream | ||
if (iopts && (iopts.writable || iopts._writableState)) { | ||
istream = iopts | ||
iopts = defaultOptions | ||
var pinoPrototype = Object.create(EventEmitter.prototype, { | ||
silent: { | ||
value: tools.noop, | ||
enumerable: true | ||
}, | ||
stream: { | ||
value: process.stdout, | ||
writable: true | ||
} | ||
iopts = Object.assign({}, defaultOptions, iopts) | ||
if (iopts.extreme && iopts.prettyPrint) throw Error('cannot enable pretty print in extreme mode') | ||
istream = istream || process.stdout | ||
if (iopts.prettyPrint) { | ||
var pstream = pretty(iopts.prettyPrint) | ||
var origStream = istream | ||
pump(pstream, origStream, function (err) { | ||
if (err) logger.emit('error', err) | ||
}) | ||
istream = pstream | ||
} | ||
}) | ||
// internal options | ||
iopts.stringify = iopts.safe ? stringifySafe : JSON.stringify | ||
iopts.formatOpts = {lowres: true} | ||
iopts.end = ',"v":' + LOG_VERSION + '}\n' | ||
iopts.cache = !iopts.extreme ? null : { | ||
size: 4096, | ||
buf: '' | ||
} | ||
iopts.chindings = '' | ||
var levelMethods = ['fatal', 'error', 'warn', 'info', 'debug', 'trace'] | ||
levelMethods.forEach(function (m) { | ||
Object.defineProperty(pinoPrototype, m, { | ||
value: tools.genLog(levels.levels[m]), | ||
enumerable: true, | ||
writable: true | ||
}) | ||
}) | ||
if (iopts.enabled === false) { | ||
iopts.level = 'silent' | ||
} | ||
var settleTries = 0 | ||
function waitForFDSettle () { | ||
var isBlockable = tools.streamIsBlockable(istream) | ||
if (isBlockable === false && settleTries > 10) { | ||
return logger.emit('error', Error('stream must have a file descriptor in extreme mode')) | ||
} else if (isBlockable === true) { | ||
return events(logger, extremeModeExitHandler) | ||
} | ||
settleTries += 1 | ||
setTimeout(waitForFDSettle, 100) | ||
} | ||
function extremeModeExitHandler () { | ||
var buf = iopts.cache.buf | ||
if (buf) { | ||
// We need to block the process exit long enough to flush the buffer | ||
// to the destination stream. We do that by forcing a synchronous | ||
// write directly to the stream's file descriptor. | ||
var fd = (istream.fd) ? istream.fd : istream._handle.fd | ||
fs.writeSync(fd, buf) | ||
} | ||
} | ||
var logger = new Pino(iopts, istream) | ||
if (iopts.cache) setTimeout(waitForFDSettle, 100) | ||
return logger | ||
} | ||
tools.defineLevelsProperty(pino) | ||
function Pino (opts, stream) { | ||
// We define the levels property at construction so that state does | ||
// not get shared between instances. | ||
tools.defineLevelsProperty(this) | ||
this.stream = stream | ||
tools.applyOptions.call(this, opts) | ||
} | ||
Pino.prototype = new EventEmitter() | ||
Pino.prototype.fatal = tools.genLog(levels.levels.fatal) | ||
Pino.prototype.error = tools.genLog(levels.levels.error) | ||
Pino.prototype.warn = tools.genLog(levels.levels.warn) | ||
Pino.prototype.info = tools.genLog(levels.levels.info) | ||
Pino.prototype.debug = tools.genLog(levels.levels.debug) | ||
Pino.prototype.trace = tools.genLog(levels.levels.trace) | ||
Pino.prototype.silent = tools.noop | ||
Object.defineProperty(Pino.prototype, 'levelVal', { | ||
Object.defineProperty(pinoPrototype, 'levelVal', { | ||
get: function getLevelVal () { | ||
@@ -134,3 +72,3 @@ return this._levelVal | ||
} | ||
this[key] = levels.isStandardLevel(key) ? Pino.prototype[key] : tools.genLog(this.levels.values[key]) | ||
this[key] = levels.isStandardLevel(key) ? pinoPrototype[key] : tools.genLog(this.levels.values[key]) | ||
} | ||
@@ -140,26 +78,30 @@ } | ||
Pino.prototype._setLevel = function _setLevel (level) { | ||
if (typeof level === 'number') { | ||
if (!isFinite(level)) { | ||
Object.defineProperty(pinoPrototype, '_setLevel', { | ||
value: function _setLevel (level) { | ||
if (typeof level === 'number') { | ||
if (!isFinite(level)) { | ||
throw Error('unknown level ' + level) | ||
} | ||
level = this.levels.labels[level] | ||
} | ||
if (!this.levels.values[level]) { | ||
throw Error('unknown level ' + level) | ||
} | ||
level = this.levels.labels[level] | ||
this.levelVal = this.levels.values[level] | ||
} | ||
}) | ||
if (!this.levels.values[level]) { | ||
throw Error('unknown level ' + level) | ||
Object.defineProperty(pinoPrototype, '_getLevel', { | ||
value: function _getLevel (level) { | ||
return this.levels.labels[this.levelVal] | ||
} | ||
this.levelVal = this.levels.values[level] | ||
} | ||
}) | ||
Pino.prototype._getLevel = function _getLevel (level) { | ||
return this.levels.labels[this.levelVal] | ||
} | ||
Object.defineProperty(Pino.prototype, 'level', { | ||
get: Pino.prototype._getLevel, | ||
set: Pino.prototype._setLevel | ||
Object.defineProperty(pinoPrototype, 'level', { | ||
get: pinoPrototype._getLevel, | ||
set: pinoPrototype._setLevel | ||
}) | ||
Object.defineProperty(Pino.prototype, '_lscache', { | ||
Object.defineProperty(pinoPrototype, '_lscache', { | ||
value: tools.copy({}, levels.lscache) | ||
@@ -169,3 +111,3 @@ }) | ||
Object.defineProperty( | ||
Pino.prototype, | ||
pinoPrototype, | ||
'LOG_VERSION', | ||
@@ -175,100 +117,182 @@ {value: LOG_VERSION} | ||
Pino.prototype.asJson = function asJson (obj, msg, num) { | ||
if (!msg && obj instanceof Error) { | ||
msg = obj.message | ||
} | ||
var data = this._baseLog + this._lscache[num] + this.time() | ||
// to catch both null and undefined | ||
/* eslint-disable eqeqeq */ | ||
if (msg != undefined) { | ||
data += ',"msg":' + JSON.stringify('' + msg) | ||
} | ||
var value | ||
if (obj) { | ||
if (obj.stack) { | ||
data += ',"type":"Error","stack":' + this.stringify(obj.stack) | ||
Object.defineProperty(pinoPrototype, 'asJson', { | ||
enumerable: true, | ||
value: function asJson (obj, msg, num) { | ||
if (!msg && obj instanceof Error) { | ||
msg = obj.message | ||
} | ||
for (var key in obj) { | ||
value = obj[key] | ||
if ((!obj.hasOwnProperty || obj.hasOwnProperty(key)) && value !== undefined) { | ||
value = this.stringify(this.serializers[key] ? this.serializers[key](value) : value) | ||
if (value !== undefined) { | ||
data += ',"' + key + '":' + value | ||
var data = this._baseLog + this._lscache[num] + this.time() | ||
// to catch both null and undefined | ||
/* eslint-disable eqeqeq */ | ||
if (msg != undefined) { | ||
data += ',"msg":' + JSON.stringify('' + msg) | ||
} | ||
var value | ||
if (obj) { | ||
if (obj.stack) { | ||
data += ',"type":"Error","stack":' + this.stringify(obj.stack) | ||
} | ||
for (var key in obj) { | ||
value = obj[key] | ||
if ((!obj.hasOwnProperty || obj.hasOwnProperty(key)) && value !== undefined) { | ||
value = this.stringify(this.serializers[key] ? this.serializers[key](value) : value) | ||
if (value !== undefined) { | ||
data += ',"' + key + '":' + value | ||
} | ||
} | ||
} | ||
} | ||
return data + this.chindings + this.end | ||
} | ||
return data + this.chindings + this.end | ||
} | ||
}) | ||
Pino.prototype.child = function child (bindings) { | ||
if (!bindings) { | ||
throw Error('missing bindings for child Pino') | ||
} | ||
Object.defineProperty(pinoPrototype, 'child', { | ||
enumerable: true, | ||
value: function child (bindings) { | ||
if (!bindings) { | ||
throw Error('missing bindings for child Pino') | ||
} | ||
var data = ',' | ||
var value | ||
var key | ||
for (key in bindings) { | ||
value = bindings[key] | ||
if (key !== 'level' && key !== 'serializers' && bindings.hasOwnProperty(key) && value !== undefined) { | ||
value = this.serializers[key] ? this.serializers[key](value) : value | ||
data += '"' + key + '":' + this.stringify(value) + ',' | ||
var data = ',' | ||
var value | ||
var key | ||
for (key in bindings) { | ||
value = bindings[key] | ||
if (key !== 'level' && key !== 'serializers' && bindings.hasOwnProperty(key) && value !== undefined) { | ||
value = this.serializers[key] ? this.serializers[key](value) : value | ||
data += '"' + key + '":' + this.stringify(value) + ',' | ||
} | ||
} | ||
} | ||
data = this.chindings + data.substr(0, data.length - 1) | ||
data = this.chindings + data.substr(0, data.length - 1) | ||
var opts = { | ||
level: bindings.level || this.level, | ||
levelVal: levels.isStandardLevelVal(this.levelVal) ? undefined : this.levelVal, | ||
serializers: bindings.hasOwnProperty('serializers') ? Object.assign({}, this.serializers, bindings.serializers) : this.serializers, | ||
stringify: this.stringify, | ||
end: this.end, | ||
name: this.name, | ||
timestamp: this.timestamp, | ||
slowtime: this.slowtime, | ||
chindings: data, | ||
cache: this.cache, | ||
formatOpts: this.formatOpts | ||
var opts = { | ||
level: bindings.level || this.level, | ||
levelVal: levels.isStandardLevelVal(this.levelVal) ? undefined : this.levelVal, | ||
serializers: bindings.hasOwnProperty('serializers') ? Object.assign({}, this.serializers, bindings.serializers) : this.serializers, | ||
stringify: this.stringify, | ||
end: this.end, | ||
name: this.name, | ||
timestamp: this.timestamp, | ||
slowtime: this.slowtime, | ||
chindings: data, | ||
cache: this.cache, | ||
formatOpts: this.formatOpts | ||
} | ||
var _child = Object.create(this) | ||
_child.stream = this.stream | ||
tools.applyOptions.call(_child, opts) | ||
return _child | ||
} | ||
}) | ||
var _child = Object.create(this) | ||
_child.stream = this.stream | ||
tools.applyOptions.call(_child, opts) | ||
return _child | ||
} | ||
// should this be enumerable? | ||
Object.defineProperty(pinoPrototype, 'write', { | ||
value: function (obj, msg, num) { | ||
var s = this.asJson(obj, msg, num) | ||
if (!this.cache) { | ||
this.stream.write(flatstr(s)) | ||
return | ||
} | ||
Pino.prototype.write = function (obj, msg, num) { | ||
var s = this.asJson(obj, msg, num) | ||
if (!this.cache) { | ||
this.stream.write(flatstr(s)) | ||
return | ||
this.cache.buf += s | ||
if (this.cache.buf.length > this.cache.size) { | ||
this.stream.write(flatstr(this.cache.buf)) | ||
this.cache.buf = '' | ||
} | ||
} | ||
}) | ||
this.cache.buf += s | ||
if (this.cache.buf.length > this.cache.size) { | ||
Object.defineProperty(pinoPrototype, 'flush', { | ||
enumerable: true, | ||
value: function () { | ||
if (!this.cache) { | ||
return | ||
} | ||
this.stream.write(flatstr(this.cache.buf)) | ||
this.cache.buf = '' | ||
} | ||
} | ||
}) | ||
Pino.prototype.flush = function () { | ||
if (!this.cache) { | ||
return | ||
Object.defineProperty(pinoPrototype, 'addLevel', { | ||
enumerable: true, | ||
value: function addLevel (name, lvl) { | ||
if (this.levels.values.hasOwnProperty(name)) return false | ||
if (this.levels.labels.hasOwnProperty(lvl)) return false | ||
this.levels.values[name] = lvl | ||
this.levels.labels[lvl] = name | ||
this._lscache[lvl] = flatstr('"level":' + Number(lvl)) | ||
this[name] = tools.genLog(lvl) | ||
return true | ||
} | ||
}) | ||
this.stream.write(flatstr(this.cache.buf)) | ||
this.cache.buf = '' | ||
} | ||
function pino (opts, stream) { | ||
var iopts = opts | ||
var istream = stream | ||
if (iopts && (iopts.writable || iopts._writableState)) { | ||
istream = iopts | ||
iopts = defaultOptions | ||
} | ||
iopts = Object.assign({}, defaultOptions, iopts) | ||
if (iopts.extreme && iopts.prettyPrint) throw Error('cannot enable pretty print in extreme mode') | ||
istream = istream || process.stdout | ||
if (iopts.prettyPrint) { | ||
var pstream = pretty(iopts.prettyPrint) | ||
var origStream = istream | ||
pump(pstream, origStream, function (err) { | ||
if (err) instance.emit('error', err) | ||
}) | ||
istream = pstream | ||
} | ||
Pino.prototype.addLevel = function addLevel (name, lvl) { | ||
if (this.levels.values.hasOwnProperty(name)) return false | ||
if (this.levels.labels.hasOwnProperty(lvl)) return false | ||
this.levels.values[name] = lvl | ||
this.levels.labels[lvl] = name | ||
this._lscache[lvl] = flatstr('"level":' + Number(lvl)) | ||
this[name] = tools.genLog(lvl) | ||
return true | ||
// internal options | ||
iopts.stringify = iopts.safe ? stringifySafe : JSON.stringify | ||
iopts.formatOpts = {lowres: true} | ||
iopts.end = ',"v":' + LOG_VERSION + '}\n' | ||
iopts.cache = !iopts.extreme ? null : { | ||
size: 4096, | ||
buf: '' | ||
} | ||
iopts.chindings = '' | ||
if (iopts.enabled === false) { | ||
iopts.level = 'silent' | ||
} | ||
var instance = Object.create(pinoPrototype) | ||
instance.stream = istream | ||
tools.defineLevelsProperty(instance) | ||
tools.applyOptions.call(instance, iopts) | ||
if (iopts.cache) setTimeout(waitForFDSettle, 100) | ||
var settleTries = 0 | ||
function waitForFDSettle () { | ||
var isBlockable = tools.streamIsBlockable(istream) | ||
if (isBlockable === false && settleTries > 10) { | ||
return instance.emit('error', Error('stream must have a file descriptor in extreme mode')) | ||
} else if (isBlockable === true) { | ||
return events(instance, extremeModeExitHandler) | ||
} | ||
settleTries += 1 | ||
setTimeout(waitForFDSettle, 100) | ||
} | ||
function extremeModeExitHandler () { | ||
var buf = iopts.cache.buf | ||
if (buf) { | ||
// We need to block the process exit long enough to flush the buffer | ||
// to the destination stream. We do that by forcing a synchronous | ||
// write directly to the stream's file descriptor. | ||
var fd = (istream.fd) ? istream.fd : istream._handle.fd | ||
fs.writeSync(fd, buf) | ||
} | ||
} | ||
return instance | ||
} | ||
tools.defineLevelsProperty(pino) | ||
module.exports = pino | ||
@@ -286,9 +310,1 @@ module.exports.stdSerializers = { | ||
) | ||
// This is an internal API. It can change at any time, including semver-minor. | ||
// Use it at your own risk. | ||
Object.defineProperty( | ||
module.exports, | ||
'_Pino', | ||
{value: Pino} | ||
) |
@@ -1,3 +0,1 @@ | ||
#! /usr/bin/env node | ||
'use strict' | ||
@@ -142,23 +140,1 @@ | ||
module.exports = pretty | ||
if (require.main === module) { | ||
if (arg('-h') || arg('--help')) { | ||
usage().pipe(process.stdout) | ||
} else if (arg('-v') || arg('--version')) { | ||
console.log(require('./package.json').version) | ||
} else { | ||
process.stdin.pipe(pretty({ | ||
timeTransOnly: arg('-t'), | ||
levelFirst: arg('-l') | ||
})).pipe(process.stdout) | ||
} | ||
} | ||
function usage () { | ||
return require('fs') | ||
.createReadStream(require('path').join(__dirname, 'usage.txt')) | ||
} | ||
function arg (s) { | ||
return !!~process.argv.indexOf(s) | ||
} |
@@ -255,2 +255,1 @@ 'use strict' | ||
} | ||
@@ -122,2 +122,36 @@ 'use strict' | ||
test('level-change event', function (t) { | ||
var instance = pino() | ||
var handle = function (lvl, val, prevLvl, prevVal) { | ||
t.is(lvl, 'trace') | ||
t.is(val, 10) | ||
t.is(prevLvl, 'info') | ||
t.is(prevVal, 30) | ||
} | ||
instance.on('level-change', handle) | ||
instance.level = 'trace' | ||
instance.removeListener('level-change', handle) | ||
instance.level = 'info' | ||
var count = 0 | ||
var l1 = function () { count += 1 } | ||
var l2 = function () { count += 1 } | ||
var l3 = function () { count += 1 } | ||
instance.on('level-change', l1) | ||
instance.on('level-change', l2) | ||
instance.on('level-change', l3) | ||
instance.level = 'trace' | ||
instance.removeListener('level-change', l3) | ||
instance.level = 'fatal' | ||
instance.removeListener('level-change', l1) | ||
instance.level = 'debug' | ||
instance.removeListener('level-change', l2) | ||
instance.level = 'info' | ||
t.is(count, 6) | ||
t.end() | ||
}) | ||
test('enable', function (t) { | ||
@@ -223,35 +257,1 @@ var instance = pino({ | ||
}) | ||
test('level-change event', function (t) { | ||
var instance = pino() | ||
var handle = function (lvl, val, prevLvl, prevVal) { | ||
t.is(lvl, 'trace') | ||
t.is(val, 10) | ||
t.is(prevLvl, 'info') | ||
t.is(prevVal, 30) | ||
} | ||
instance.on('level-change', handle) | ||
instance.level = 'trace' | ||
instance.removeListener('level-change', handle) | ||
instance.level = 'info' | ||
var count = 0 | ||
var l1 = function () { count += 1 } | ||
var l2 = function () { count += 1 } | ||
var l3 = function () { count += 1 } | ||
instance.on('level-change', l1) | ||
instance.on('level-change', l2) | ||
instance.on('level-change', l3) | ||
instance.level = 'trace' | ||
instance.removeListener('level-change', l3) | ||
instance.level = 'fatal' | ||
instance.removeListener('level-change', l1) | ||
instance.level = 'debug' | ||
instance.removeListener('level-change', l2) | ||
instance.level = 'info' | ||
t.is(count, 6) | ||
t.end() | ||
}) |
@@ -5,2 +5,3 @@ 'use strict' | ||
var pino = require('../') | ||
var pretty = require('../pretty') | ||
var os = require('os') | ||
@@ -15,4 +16,4 @@ var path = require('path') | ||
t.plan(4) | ||
var pretty = pino.pretty() | ||
pretty.pipe(split(function (line) { | ||
var prettier = pretty() | ||
prettier.pipe(split(function (line) { | ||
t.ok(line.match(/.*hello world$/), 'end of line matches') | ||
@@ -24,3 +25,3 @@ t.ok(line.match(/(?!^)INFO.*/), 'includes level') | ||
})) | ||
var instance = pino(pretty) | ||
var instance = pino(prettier) | ||
@@ -32,4 +33,4 @@ instance.info('hello world') | ||
t.plan(4) | ||
var pretty = pino.pretty({ levelFirst: true }) | ||
pretty.pipe(split(function (line) { | ||
var prettier = pretty({ levelFirst: true }) | ||
prettier.pipe(split(function (line) { | ||
t.ok(line.match(/.*hello world$/), 'end of line matches') | ||
@@ -41,3 +42,3 @@ t.ok(line.match(/^INFO.*/), 'level is at start of line') | ||
})) | ||
var instance = pino(pretty) | ||
var instance = pino(prettier) | ||
@@ -49,4 +50,4 @@ instance.info('hello world') | ||
t.plan(1) | ||
var pretty = pino.pretty({ timeTransOnly: true }) | ||
pretty.pipe(split(function (line) { | ||
var prettier = pretty({ timeTransOnly: true }) | ||
prettier.pipe(split(function (line) { | ||
var obj = JSON.parse(line) | ||
@@ -56,3 +57,3 @@ t.ok(typeof obj.time === 'string', 'time is a string') | ||
})) | ||
var instance = pino(pretty) | ||
var instance = pino(prettier) | ||
@@ -64,10 +65,10 @@ instance.info('hello world') | ||
t.plan(1) | ||
var pretty = pino.pretty({ formatter: function (line) { | ||
var prettier = pretty({ formatter: function (line) { | ||
return 'msg: ' + line.msg + ', foo: ' + line.foo | ||
} }) | ||
pretty.pipe(split(function (line) { | ||
prettier.pipe(split(function (line) { | ||
t.ok(line === 'msg: hello world, foo: bar', 'line matches') | ||
return line | ||
})) | ||
var instance = pino(pretty) | ||
var instance = pino(prettier) | ||
@@ -78,3 +79,3 @@ instance.info({foo: 'bar'}, 'hello world') | ||
test('pino transform prettifies Error', function (t) { | ||
var pretty = pino.pretty() | ||
var prettier = pretty() | ||
var err = new Error('hello world') | ||
@@ -86,3 +87,3 @@ var expected = err.stack.split('\n') | ||
pretty.pipe(split(function (line) { | ||
prettier.pipe(split(function (line) { | ||
t.ok(line.indexOf(expected.shift()) >= 0, 'line matches') | ||
@@ -92,3 +93,3 @@ return line | ||
var instance = pino(pretty) | ||
var instance = pino(prettier) | ||
@@ -100,5 +101,5 @@ instance.info(err) | ||
t.plan(1) | ||
var pretty = pino.pretty() | ||
var prettier = pretty() | ||
var lines = [] | ||
pretty.pipe(split(function (line) { | ||
prettier.pipe(split(function (line) { | ||
lines.push(line) | ||
@@ -108,4 +109,4 @@ return line | ||
pretty.write('this is not json\nit\'s just regular output\n') | ||
pretty.end() | ||
prettier.write('this is not json\nit\'s just regular output\n') | ||
prettier.end() | ||
@@ -117,5 +118,5 @@ t.deepEqual(lines, ['this is not json', 'it\'s just regular output'], 'preserved lines') | ||
t.plan(1) | ||
var pretty = pino.pretty() | ||
var prettier = pretty() | ||
var lines = [] | ||
pretty.pipe(split(function (line) { | ||
prettier.pipe(split(function (line) { | ||
lines.push(line) | ||
@@ -125,4 +126,4 @@ return line | ||
pretty.write('{"hello":"world"}') | ||
pretty.end() | ||
prettier.write('{"hello":"world"}') | ||
prettier.end() | ||
@@ -134,5 +135,5 @@ t.deepEqual(lines, ['{"hello":"world"}'], 'preserved lines') | ||
t.plan(1) | ||
var pretty = pino.pretty() | ||
var prettier = pretty() | ||
var first = true | ||
pretty.pipe(split(function (line) { | ||
prettier.pipe(split(function (line) { | ||
if (first) { | ||
@@ -145,3 +146,3 @@ first = false | ||
})) | ||
var instance = pino(pretty) | ||
var instance = pino(prettier) | ||
@@ -153,8 +154,8 @@ instance.info({ a: 'b' }, 'hello world') | ||
t.plan(1) | ||
var pretty = pino.pretty() | ||
pretty.pipe(split(function (line) { | ||
var prettier = pretty() | ||
prettier.pipe(split(function (line) { | ||
t.ok(line.match(/\(matteo\/.*$/), 'includes the name') | ||
return line | ||
})) | ||
var instance = pino({ name: 'matteo' }, pretty) | ||
var instance = pino({ name: 'matteo' }, prettier) | ||
@@ -166,9 +167,9 @@ instance.info('hello world') | ||
t.plan(1) | ||
var pretty = pino.pretty() | ||
pretty.pipe(split(function (line) { | ||
var prettier = pretty() | ||
prettier.pipe(split(function (line) { | ||
t.is(line, 'null') | ||
return line | ||
})) | ||
pretty.write('null') | ||
pretty.end() | ||
prettier.write('null') | ||
prettier.end() | ||
}) | ||
@@ -178,9 +179,9 @@ | ||
t.plan(1) | ||
var pretty = pino.pretty() | ||
pretty.pipe(split(function (line) { | ||
var prettier = pretty() | ||
prettier.pipe(split(function (line) { | ||
t.is(line, 'undefined') | ||
return line | ||
})) | ||
pretty.write('undefined') | ||
pretty.end() | ||
prettier.write('undefined') | ||
prettier.end() | ||
}) | ||
@@ -190,9 +191,9 @@ | ||
t.plan(1) | ||
var pretty = pino.pretty() | ||
pretty.pipe(split(function (line) { | ||
var prettier = pretty() | ||
prettier.pipe(split(function (line) { | ||
t.is(line, 'true') | ||
return line | ||
})) | ||
pretty.write('true') | ||
pretty.end() | ||
prettier.write('true') | ||
prettier.end() | ||
}) | ||
@@ -202,5 +203,5 @@ | ||
t.plan(1) | ||
var pretty = pino.pretty() | ||
var prettier = pretty() | ||
pretty.pipe(split(function (line) { | ||
prettier.pipe(split(function (line) { | ||
t.ok(line.indexOf('USERLVL') > 0, 'include custom level') | ||
@@ -210,3 +211,3 @@ return line | ||
var instance = pino({level: 'testCustom', levelVal: 35}, pretty) | ||
var instance = pino({level: 'testCustom', levelVal: 35}, prettier) | ||
@@ -213,0 +214,0 @@ instance.testCustom('test message') |
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
15
116787
19
2691