mirror of
https://github.com/pinojs/pino.git
synced 2026-02-01 17:46:06 +00:00
Replacing var with let/const, somewhere left var because scope, somewhere left var because for + resolved all standard issues
This commit is contained in:
parent
40fa7f6e7a
commit
2fd82b761f
@ -43,48 +43,56 @@ const chill = winston.createLogger({
|
||||
|
||||
const run = bench([
|
||||
function benchBunyan (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinston (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBole (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchDebug (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
dlog('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchLogLevel (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
loglevel.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPino (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsync (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStream (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello world')
|
||||
}
|
||||
|
||||
@ -24,24 +24,28 @@ const blog = bunyan.createLogger({
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info({ hello: 'world' })
|
||||
}
|
||||
|
||||
@ -27,35 +27,40 @@ require('bole').output({
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanCreation (cb) {
|
||||
var child = blog.child({ a: 'property' })
|
||||
const child = blog.child({ a: 'property' })
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleCreation (cb) {
|
||||
var child = bole('child')
|
||||
const child = bole('child')
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoCreation (cb) {
|
||||
var child = plogDest.child({ a: 'property' })
|
||||
const child = plogDest.child({ a: 'property' })
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncCreation (cb) {
|
||||
var child = plogAsync.child({ a: 'property' })
|
||||
const child = plogAsync.child({ a: 'property' })
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamCreation (cb) {
|
||||
var child = plogNodeStream.child({ a: 'property' })
|
||||
const child = plogNodeStream.child({ a: 'property' })
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
|
||||
@ -28,30 +28,35 @@ require('bole').output({
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAssyncChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info({ hello: 'world' })
|
||||
}
|
||||
|
||||
@ -42,42 +42,49 @@ const chill = winston.createLogger({
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchLogLevelDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
loglevel.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info(deep)
|
||||
}
|
||||
|
||||
@ -34,12 +34,14 @@ const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchPinoNoFormatters (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
pinoNoFormatters.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoFormatters (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
pinoFormatters.info({ hello: 'world' })
|
||||
}
|
||||
|
||||
@ -17,30 +17,35 @@ const max = 100
|
||||
|
||||
const run = bench([
|
||||
function benchPinoNoCustomLevel (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
base.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoCustomLevel (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
baseCl.foo({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchChildNoCustomLevel (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildCustomLevel (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
childCl.foo({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildInheritedCustomLevel (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
childOfBaseCl.foo({ hello: 'world' })
|
||||
}
|
||||
@ -48,6 +53,7 @@ const run = bench([
|
||||
},
|
||||
function benchPinoChildCreation (cb) {
|
||||
const child = base.child({})
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
@ -57,6 +63,7 @@ const run = bench([
|
||||
const child = base.child({
|
||||
customLevels: { foo: 31 }
|
||||
})
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.foo({ hello: 'world' })
|
||||
}
|
||||
|
||||
@ -18,54 +18,63 @@ const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchPinoLongString (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestLongString (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncLongString (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncDeepObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %j', deep)
|
||||
}
|
||||
|
||||
@ -20,158 +20,184 @@ const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchPino (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDest (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoExtreme (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDestChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsyncChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDestChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsyncChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildCreation (cb) {
|
||||
var child = plog.child({ a: 'property' })
|
||||
const child = plog.child({ a: 'property' })
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestChildCreation (cb) {
|
||||
var child = plogDest.child({ a: 'property' })
|
||||
const child = plogDest.child({ a: 'property' })
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMulti (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestMulti (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncMulti (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
|
||||
@ -17,54 +17,63 @@ const max = 100
|
||||
|
||||
const run = bench([
|
||||
function benchPinoBase (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
base.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
childChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
childChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChildChildChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
childChildChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChild2 (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
child2.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoBaseSerilalizers (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
baseSerializers.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoBaseSerilalizersChild (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
baseSerializersChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoBaseSerilalizersChildSeriazliers (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
baseSerializersChildSerializers.info({ hello: 'world' })
|
||||
}
|
||||
|
||||
@ -34,48 +34,56 @@ const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchPinoNoRedact (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoRedact (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogRedact.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoUnsafeNoRedact (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogUnsafe.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoUnsafeRedact (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogUnsafeRedact.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncNoRedact (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncRedact (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsyncRedact.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoUnsafeAsyncNoRedact (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogUnsafeAsync.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoUnsafeAsyncRedact (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogUnsafeAsyncRedact.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ require('bole').output({
|
||||
stream: dest
|
||||
}).setFastTime(true)
|
||||
|
||||
var chill = winston.createLogger({
|
||||
const chill = winston.createLogger({
|
||||
transports: [
|
||||
new winston.transports.Stream({
|
||||
stream: fs.createWriteStream('/dev/null')
|
||||
@ -39,38 +39,44 @@ var chill = winston.createLogger({
|
||||
]
|
||||
})
|
||||
|
||||
var run = bench([
|
||||
const run = bench([
|
||||
function benchBunyan (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinston (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBole (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPino (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsync (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStream (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info(longStr)
|
||||
}
|
||||
|
||||
@ -44,42 +44,49 @@ const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamInterpolate (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBunyanInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
@ -87,102 +94,119 @@ const run = bench([
|
||||
},
|
||||
|
||||
function benchWinstonInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamInterpolateAll (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBunyanInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamInterpolateExtra (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBunyanInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamInterpolateDeep (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello %j', deep)
|
||||
}
|
||||
|
||||
@ -36,42 +36,49 @@ const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchLogLevelObject (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
loglevel.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamObj (cb) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info({ hello: 'world' })
|
||||
}
|
||||
|
||||
@ -90,7 +90,8 @@ function runBenchmark (name, done) {
|
||||
}
|
||||
|
||||
function sum (arr) {
|
||||
var result = 0
|
||||
let result = 0
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < arr.length; i += 1) {
|
||||
result += Number.parseFloat(arr[i].time)
|
||||
}
|
||||
@ -100,13 +101,14 @@ function sum (arr) {
|
||||
function displayResults (results) {
|
||||
if (quiet === false) console.log('==========')
|
||||
const benchNames = Object.keys(results)
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < benchNames.length; i += 1) {
|
||||
console.log(`${benchNames[i].toUpperCase()} benchmark averages`)
|
||||
const benchmark = results[benchNames[i]]
|
||||
const loggers = Object.keys(benchmark)
|
||||
for (var j = 0; j < loggers.length; j += 1) {
|
||||
var logger = benchmark[loggers[j]]
|
||||
var average = sum(logger) / logger.length
|
||||
const logger = benchmark[loggers[j]]
|
||||
const average = sum(logger) / logger.length
|
||||
console.log(`${loggers[j]} average: ${average.toFixed(3)}ms`)
|
||||
}
|
||||
}
|
||||
@ -128,6 +130,7 @@ if (selectedBenchmark !== 'all') {
|
||||
benchQueue.push(toBench.bind({ name: selectedBenchmark }))
|
||||
} else {
|
||||
const keys = Object.keys(benchmarks)
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < keys.length; i += 1) {
|
||||
benchQueue.push(toBench.bind({ name: keys[i] }))
|
||||
}
|
||||
|
||||
@ -9,30 +9,31 @@ const code = readFileSync(
|
||||
const { Console } = require('console')
|
||||
|
||||
function build (dest) {
|
||||
var sandbox = {
|
||||
const sandbox = {
|
||||
module: {},
|
||||
console: new Console(dest, dest)
|
||||
}
|
||||
var context = vm.createContext(sandbox)
|
||||
const context = vm.createContext(sandbox)
|
||||
|
||||
var script = new vm.Script(code)
|
||||
const script = new vm.Script(code)
|
||||
script.runInContext(context)
|
||||
|
||||
var loglevel = sandbox.log
|
||||
const loglevel = sandbox.log
|
||||
|
||||
var originalFactory = loglevel.methodFactory
|
||||
const originalFactory = loglevel.methodFactory
|
||||
loglevel.methodFactory = function (methodName, logLevel, loggerName) {
|
||||
var rawMethod = originalFactory(methodName, logLevel, loggerName)
|
||||
const rawMethod = originalFactory(methodName, logLevel, loggerName)
|
||||
|
||||
return function () {
|
||||
var time = new Date()
|
||||
var array
|
||||
const time = new Date()
|
||||
let array
|
||||
if (typeof arguments[0] === 'string') {
|
||||
arguments[0] = '[' + time.toISOString() + '] ' + arguments[0]
|
||||
rawMethod.apply(null, arguments)
|
||||
} else {
|
||||
array = new Array(arguments.length + 1)
|
||||
array[0] = '[' + time.toISOString() + ']'
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
array[i + 1] = arguments[i]
|
||||
}
|
||||
@ -48,7 +49,7 @@ function build (dest) {
|
||||
module.exports = build
|
||||
|
||||
if (require.main === module) {
|
||||
var loglevel = build(process.stdout)
|
||||
const loglevel = build(process.stdout)
|
||||
loglevel.info('hello')
|
||||
loglevel.info({ hello: 'world' })
|
||||
loglevel.info('hello %j', { hello: 'world' })
|
||||
|
||||
75
browser.js
75
browser.js
@ -1,11 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
var format = require('quick-format-unescaped')
|
||||
const format = require('quick-format-unescaped')
|
||||
|
||||
module.exports = pino
|
||||
|
||||
var _console = pfGlobalThisOrFallback().console || {}
|
||||
var stdSerializers = {
|
||||
const _console = pfGlobalThisOrFallback().console || {}
|
||||
const stdSerializers = {
|
||||
mapHttpRequest: mock,
|
||||
mapHttpResponse: mock,
|
||||
wrapRequestSerializer: passthrough,
|
||||
@ -20,33 +20,33 @@ function pino (opts) {
|
||||
opts = opts || {}
|
||||
opts.browser = opts.browser || {}
|
||||
|
||||
var transmit = opts.browser.transmit
|
||||
const transmit = opts.browser.transmit
|
||||
if (transmit && typeof transmit.send !== 'function') { throw Error('pino: transmit option must have a send function') }
|
||||
|
||||
var proto = opts.browser.write || _console
|
||||
const proto = opts.browser.write || _console
|
||||
if (opts.browser.write) opts.browser.asObject = true
|
||||
var serializers = opts.serializers || {}
|
||||
var serialize = Array.isArray(opts.browser.serialize)
|
||||
const serializers = opts.serializers || {}
|
||||
const serialize = Array.isArray(opts.browser.serialize)
|
||||
? opts.browser.serialize.filter(function (k) {
|
||||
return k !== '!stdSerializers.err'
|
||||
})
|
||||
return k !== '!stdSerializers.err'
|
||||
})
|
||||
: opts.browser.serialize === true ? Object.keys(serializers) : false
|
||||
var stdErrSerialize = opts.browser.serialize
|
||||
let stdErrSerialize = opts.browser.serialize
|
||||
|
||||
if (
|
||||
Array.isArray(opts.browser.serialize) &&
|
||||
opts.browser.serialize.indexOf('!stdSerializers.err') > -1
|
||||
) stdErrSerialize = false
|
||||
|
||||
var levels = ['error', 'fatal', 'warn', 'info', 'debug', 'trace']
|
||||
const levels = ['error', 'fatal', 'warn', 'info', 'debug', 'trace']
|
||||
|
||||
if (typeof proto === 'function') {
|
||||
proto.error = proto.fatal = proto.warn =
|
||||
proto.info = proto.debug = proto.trace = proto
|
||||
}
|
||||
if (opts.enabled === false) opts.level = 'silent'
|
||||
var level = opts.level || 'info'
|
||||
var logger = Object.create(proto)
|
||||
const level = opts.level || 'info'
|
||||
const logger = Object.create(proto)
|
||||
if (!logger.log) logger.log = noop
|
||||
|
||||
Object.defineProperty(logger, 'levelVal', {
|
||||
@ -57,7 +57,7 @@ function pino (opts) {
|
||||
set: setLevel
|
||||
})
|
||||
|
||||
var setOpts = {
|
||||
const setOpts = {
|
||||
transmit,
|
||||
serialize,
|
||||
asObject: opts.browser.asObject,
|
||||
@ -108,7 +108,7 @@ function pino (opts) {
|
||||
if (!bindings) {
|
||||
throw new Error('missing bindings for child Pino')
|
||||
}
|
||||
var bindingsSerializers = bindings.serializers
|
||||
const bindingsSerializers = bindings.serializers
|
||||
if (serialize && bindingsSerializers) {
|
||||
var childSerializers = Object.assign({}, serializers, bindingsSerializers)
|
||||
var childSerialize = opts.browser.serialize === true
|
||||
@ -164,8 +164,9 @@ pino.stdSerializers = stdSerializers
|
||||
pino.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime })
|
||||
|
||||
function set (opts, logger, level, fallback) {
|
||||
var proto = Object.getPrototypeOf(logger)
|
||||
logger[level] = logger.levelVal > logger.levels.values[level] ? noop
|
||||
const proto = Object.getPrototypeOf(logger)
|
||||
logger[level] = logger.levelVal > logger.levels.values[level]
|
||||
? noop
|
||||
: (proto[level] ? proto[level] : (_console[level] || _console[fallback] || noop))
|
||||
|
||||
wrap(opts, logger, level)
|
||||
@ -176,9 +177,10 @@ function wrap (opts, logger, level) {
|
||||
|
||||
logger[level] = (function (write) {
|
||||
return function LOG () {
|
||||
var ts = opts.timestamp()
|
||||
var args = new Array(arguments.length)
|
||||
var proto = (Object.getPrototypeOf && Object.getPrototypeOf(this) === _console) ? _console : this
|
||||
const ts = opts.timestamp()
|
||||
const args = new Array(arguments.length)
|
||||
const proto = (Object.getPrototypeOf && Object.getPrototypeOf(this) === _console) ? _console : this
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < args.length; i++) args[i] = arguments[i]
|
||||
|
||||
if (opts.serialize && !opts.asObject) {
|
||||
@ -188,9 +190,9 @@ function wrap (opts, logger, level) {
|
||||
else write.apply(proto, args)
|
||||
|
||||
if (opts.transmit) {
|
||||
var transmitLevel = opts.transmit.level || logger.level
|
||||
var transmitValue = pino.levels.values[transmitLevel]
|
||||
var methodValue = pino.levels.values[level]
|
||||
const transmitLevel = opts.transmit.level || logger.level
|
||||
const transmitValue = pino.levels.values[transmitLevel]
|
||||
const methodValue = pino.levels.values[level]
|
||||
if (methodValue < transmitValue) return
|
||||
transmit(this, {
|
||||
ts,
|
||||
@ -208,14 +210,14 @@ function wrap (opts, logger, level) {
|
||||
|
||||
function asObject (logger, level, args, ts) {
|
||||
if (logger._serialize) applySerializers(args, logger._serialize, logger.serializers, logger._stdErrSerialize)
|
||||
var argsCloned = args.slice()
|
||||
var msg = argsCloned[0]
|
||||
var o = {}
|
||||
const argsCloned = args.slice()
|
||||
let msg = argsCloned[0]
|
||||
const o = {}
|
||||
if (ts) {
|
||||
o.time = ts
|
||||
}
|
||||
o.level = pino.levels.values[level]
|
||||
var lvl = (logger._childLevel | 0) + 1
|
||||
let lvl = (logger._childLevel | 0) + 1
|
||||
if (lvl < 1) lvl = 1
|
||||
// deliberate, catching objects, arrays
|
||||
if (msg !== null && typeof msg === 'object') {
|
||||
@ -229,6 +231,7 @@ function asObject (logger, level, args, ts) {
|
||||
}
|
||||
|
||||
function applySerializers (args, serialize, serializers, stdErrSerialize) {
|
||||
/* eslint no-var: off */
|
||||
for (var i in args) {
|
||||
if (stdErrSerialize && args[i] instanceof Error) {
|
||||
args[i] = pino.stdSerializers.err(args[i])
|
||||
@ -244,8 +247,9 @@ function applySerializers (args, serialize, serializers, stdErrSerialize) {
|
||||
|
||||
function bind (parent, bindings, level) {
|
||||
return function () {
|
||||
var args = new Array(1 + arguments.length)
|
||||
const args = new Array(1 + arguments.length)
|
||||
args[0] = bindings
|
||||
/* eslint no-var: off */
|
||||
for (var i = 1; i < args.length; i++) {
|
||||
args[i] = arguments[i - 1]
|
||||
}
|
||||
@ -254,12 +258,12 @@ function bind (parent, bindings, level) {
|
||||
}
|
||||
|
||||
function transmit (logger, opts, args) {
|
||||
var send = opts.send
|
||||
var ts = opts.ts
|
||||
var methodLevel = opts.methodLevel
|
||||
var methodValue = opts.methodValue
|
||||
var val = opts.val
|
||||
var bindings = logger._logEvent.bindings
|
||||
const send = opts.send
|
||||
const ts = opts.ts
|
||||
const methodLevel = opts.methodLevel
|
||||
const methodValue = opts.methodValue
|
||||
const val = opts.val
|
||||
const bindings = logger._logEvent.bindings
|
||||
|
||||
applySerializers(
|
||||
args,
|
||||
@ -291,11 +295,12 @@ function createLogEventShape (bindings) {
|
||||
}
|
||||
|
||||
function asErrValue (err) {
|
||||
var obj = {
|
||||
const obj = {
|
||||
type: err.constructor.name,
|
||||
msg: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
/* eslint no-var: off */
|
||||
for (var key in err) {
|
||||
if (obj[key] === undefined) {
|
||||
obj[key] = err[key]
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
height: 4em;
|
||||
}
|
||||
.markdown-section a code {
|
||||
color: var(--link-color)!important;
|
||||
color: const(--link-color)!important;
|
||||
}
|
||||
.markdown-section code:not([class*="lang-"]):not([class*="language-"]) {
|
||||
white-space: unset
|
||||
|
||||
@ -55,7 +55,8 @@ function genLsCache (instance) {
|
||||
const formatter = instance[formattersSym].level
|
||||
const { labels } = instance.levels
|
||||
const cache = {}
|
||||
for (const label in labels) {
|
||||
/* eslint no-var: off */
|
||||
for (var label in labels) {
|
||||
const level = formatter(labels[label], Number(label))
|
||||
cache[label] = JSON.stringify(level).slice(0, -1)
|
||||
}
|
||||
@ -93,6 +94,7 @@ function setLevel (level) {
|
||||
const useOnlyCustomLevelsVal = this[useOnlyCustomLevelsSym]
|
||||
const hook = this[hooksSym].logMethod
|
||||
|
||||
/* eslint no-var: off */
|
||||
for (var key in values) {
|
||||
if (levelVal > values[key]) {
|
||||
this[key] = noop
|
||||
@ -123,10 +125,12 @@ function isLevelEnabled (logLevel) {
|
||||
}
|
||||
|
||||
function mappings (customLevels = null, useOnlyCustomLevels = false) {
|
||||
const customNums = customLevels ? Object.keys(customLevels).reduce((o, k) => {
|
||||
o[customLevels[k]] = k
|
||||
return o
|
||||
}, {}) : null
|
||||
const customNums = customLevels
|
||||
? Object.keys(customLevels).reduce((o, k) => {
|
||||
o[customLevels[k]] = k
|
||||
return o
|
||||
}, {})
|
||||
: null
|
||||
|
||||
const labels = Object.assign(
|
||||
Object.create(Object.prototype, { Infinity: { value: 'silent' } }),
|
||||
@ -166,7 +170,8 @@ function assertDefaultLevelFound (defaultLevel, customLevels, useOnlyCustomLevel
|
||||
|
||||
function assertNoLevelCollisions (levels, customLevels) {
|
||||
const { labels, values } = levels
|
||||
for (const k in customLevels) {
|
||||
/* eslint no-var: off */
|
||||
for (var k in customLevels) {
|
||||
if (k in values) {
|
||||
throw Error('levels cannot be overridden')
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@ function child (bindings) {
|
||||
if (bindings.hasOwnProperty('serializers') === true) {
|
||||
instance[serializersSym] = Object.create(null)
|
||||
|
||||
/* eslint no-var: off */
|
||||
for (var k in serializers) {
|
||||
instance[serializersSym][k] = serializers[k]
|
||||
}
|
||||
@ -127,8 +128,8 @@ function child (bindings) {
|
||||
|
||||
function bindings () {
|
||||
const chindings = this[chindingsSym]
|
||||
var chindingsJson = `{${chindings.substr(1)}}` // at least contains ,"pid":7068,"hostname":"myMac"
|
||||
var bindingsFromJson = JSON.parse(chindingsJson)
|
||||
const chindingsJson = `{${chindings.substr(1)}}` // at least contains ,"pid":7068,"hostname":"myMac"
|
||||
const bindingsFromJson = JSON.parse(chindingsJson)
|
||||
delete bindingsFromJson.pid
|
||||
delete bindingsFromJson.hostname
|
||||
return bindingsFromJson
|
||||
@ -144,7 +145,7 @@ function write (_obj, msg, num) {
|
||||
const t = this[timeSym]()
|
||||
const mixin = this[mixinSym]
|
||||
const objError = _obj instanceof Error
|
||||
var obj
|
||||
let obj
|
||||
|
||||
if (_obj === undefined || _obj === null) {
|
||||
obj = mixin ? mixin({}) : {}
|
||||
|
||||
@ -85,9 +85,11 @@ function redaction (opts, serialize) {
|
||||
if (shape[k] === null) {
|
||||
o[k] = (value) => topCensor(value, [k])
|
||||
} else {
|
||||
const wrappedCensor = typeof censor === 'function' ? (value, path) => {
|
||||
return censor(value, [k, ...path])
|
||||
} : censor
|
||||
const wrappedCensor = typeof censor === 'function'
|
||||
? (value, path) => {
|
||||
return censor(value, [k, ...path])
|
||||
}
|
||||
: censor
|
||||
o[k] = fastRedact({
|
||||
paths: shape[k],
|
||||
censor: wrappedCensor,
|
||||
@ -105,7 +107,7 @@ function handle (opts) {
|
||||
validate(opts)
|
||||
return opts
|
||||
}
|
||||
var { paths, censor = CENSOR, remove } = opts
|
||||
let { paths, censor = CENSOR, remove } = opts
|
||||
if (Array.isArray(paths) === false) { throw Error('pino – redact must contain an array of strings') }
|
||||
if (remove === true) censor = undefined
|
||||
validate({ paths, censor })
|
||||
|
||||
40
lib/tools.js
40
lib/tools.js
@ -36,7 +36,7 @@ function genLog (level, hook) {
|
||||
|
||||
function LOG (o, ...n) {
|
||||
if (typeof o === 'object') {
|
||||
var msg = o
|
||||
let msg = o
|
||||
if (o !== null) {
|
||||
if (o.method && o.headers && o.socket) {
|
||||
o = mapHttpRequest(o)
|
||||
@ -45,7 +45,7 @@ function genLog (level, hook) {
|
||||
}
|
||||
}
|
||||
if (this[nestedKeySym]) o = { [this[nestedKeySym]]: o }
|
||||
var formatParams
|
||||
let formatParams
|
||||
if (msg === null && n.length === 0) {
|
||||
formatParams = [null]
|
||||
} else {
|
||||
@ -65,14 +65,15 @@ function genLog (level, hook) {
|
||||
// 34 and 92 happens all the time, so we
|
||||
// have a fast case for them
|
||||
function asString (str) {
|
||||
var result = ''
|
||||
var last = 0
|
||||
var found = false
|
||||
var point = 255
|
||||
let result = ''
|
||||
let last = 0
|
||||
let found = false
|
||||
let point = 255
|
||||
const l = str.length
|
||||
if (l > 100) {
|
||||
return JSON.stringify(str)
|
||||
}
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < l && point >= 32; i++) {
|
||||
point = str.charCodeAt(i)
|
||||
if (point === 34 || point === 92) {
|
||||
@ -97,14 +98,14 @@ function asJson (obj, msg, num, time) {
|
||||
const serializers = this[serializersSym]
|
||||
const formatters = this[formattersSym]
|
||||
const messageKey = this[messageKeySym]
|
||||
var data = this[lsCacheSym][num] + time
|
||||
let data = this[lsCacheSym][num] + time
|
||||
|
||||
// we need the child bindings added to the output first so instance logged
|
||||
// objects can take precedence when JSON.parse-ing the resulting log line
|
||||
data = data + chindings
|
||||
|
||||
var value
|
||||
var notHasOwnProperty = obj.hasOwnProperty === undefined
|
||||
let value
|
||||
const notHasOwnProperty = obj.hasOwnProperty === undefined
|
||||
if (formatters.log) {
|
||||
obj = formatters.log(obj)
|
||||
}
|
||||
@ -112,6 +113,7 @@ function asJson (obj, msg, num, time) {
|
||||
obj[messageKey] = msg
|
||||
}
|
||||
const wildcardStringifier = stringifiers[wildcardFirstSym]
|
||||
/* eslint no-var: off */
|
||||
for (var key in obj) {
|
||||
value = obj[key]
|
||||
if ((notHasOwnProperty || obj.hasOwnProperty(key)) && value !== undefined) {
|
||||
@ -148,8 +150,8 @@ function asJson (obj, msg, num, time) {
|
||||
|
||||
function asChindings (instance, bindings) {
|
||||
var key
|
||||
var value
|
||||
var data = instance[chindingsSym]
|
||||
let value
|
||||
let data = instance[chindingsSym]
|
||||
const stringify = instance[stringifySym]
|
||||
const stringifiers = instance[stringifiersSym]
|
||||
const wildcardStringifier = stringifiers[wildcardFirstSym]
|
||||
@ -157,6 +159,7 @@ function asChindings (instance, bindings) {
|
||||
const formatter = instance[formattersSym].bindings
|
||||
bindings = formatter(bindings)
|
||||
|
||||
/* eslint no-var: off */
|
||||
for (key in bindings) {
|
||||
value = bindings[key]
|
||||
const valid = key !== 'level' &&
|
||||
@ -181,7 +184,7 @@ function getPrettyStream (opts, prettifier, dest, instance) {
|
||||
return prettifierMetaWrapper(prettifier(opts), dest, opts)
|
||||
}
|
||||
try {
|
||||
var prettyFactory = require('pino-pretty')
|
||||
const prettyFactory = require('pino-pretty')
|
||||
prettyFactory.asMetaWrapper = prettifierMetaWrapper
|
||||
return prettifierMetaWrapper(prettyFactory(opts), dest, opts)
|
||||
} catch (e) {
|
||||
@ -191,7 +194,7 @@ function getPrettyStream (opts, prettifier, dest, instance) {
|
||||
|
||||
function prettifierMetaWrapper (pretty, dest, opts) {
|
||||
opts = Object.assign({ suppressFlushSyncWarning: false }, opts)
|
||||
var warned = false
|
||||
let warned = false
|
||||
return {
|
||||
[needsMetadataGsym]: true,
|
||||
lastLevel: 0,
|
||||
@ -212,7 +215,7 @@ function prettifierMetaWrapper (pretty, dest, opts) {
|
||||
},
|
||||
chindings () {
|
||||
const lastLogger = this.lastLogger
|
||||
var chindings = null
|
||||
let chindings = null
|
||||
|
||||
// protection against flushSync being called before logging
|
||||
// anything
|
||||
@ -233,7 +236,7 @@ function prettifierMetaWrapper (pretty, dest, opts) {
|
||||
const lastLogger = this.lastLogger
|
||||
const chindings = this.chindings()
|
||||
|
||||
var time = this.lastTime
|
||||
let time = this.lastTime
|
||||
|
||||
if (time.match(/^\d+/)) {
|
||||
time = parseInt(time)
|
||||
@ -241,9 +244,9 @@ function prettifierMetaWrapper (pretty, dest, opts) {
|
||||
time = time.slice(1, -1)
|
||||
}
|
||||
|
||||
var lastObj = this.lastObj
|
||||
var lastMsg = this.lastMsg
|
||||
var errorProps = null
|
||||
const lastObj = this.lastObj
|
||||
const lastMsg = this.lastMsg
|
||||
const errorProps = null
|
||||
|
||||
const formatters = lastLogger[formattersSym]
|
||||
const formattedObj = formatters.log ? formatters.log(lastObj) : lastObj
|
||||
@ -262,6 +265,7 @@ function prettifierMetaWrapper (pretty, dest, opts) {
|
||||
const keys = Object.keys(serializers)
|
||||
var key
|
||||
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
key = keys[i]
|
||||
if (obj[key] !== undefined) {
|
||||
|
||||
@ -76,7 +76,7 @@
|
||||
"semver": "^7.0.0",
|
||||
"snazzy": "^8.0.0",
|
||||
"split2": "^3.1.1",
|
||||
"standard": "^14.3.3",
|
||||
"standard": "^16.0.3",
|
||||
"steed": "^1.1.3",
|
||||
"strip-ansi": "^6.0.0",
|
||||
"tap": "^14.10.8",
|
||||
|
||||
10
pino.js
10
pino.js
@ -138,10 +138,14 @@ function pino (...args) {
|
||||
[stringifySym]: stringify,
|
||||
[formattersSym]: allFormatters
|
||||
})
|
||||
const chindings = base === null ? '' : (name === undefined)
|
||||
? coreChindings(base) : coreChindings(Object.assign({}, base, { name }))
|
||||
const chindings = base === null
|
||||
? ''
|
||||
: (name === undefined)
|
||||
? coreChindings(base)
|
||||
: coreChindings(Object.assign({}, base, { name }))
|
||||
const time = (timestamp instanceof Function)
|
||||
? timestamp : (timestamp ? epochTime : nullTime)
|
||||
? timestamp
|
||||
: (timestamp ? epochTime : nullTime)
|
||||
const timeSliceIndex = time().indexOf(':') + 1
|
||||
|
||||
if (useOnlyCustomLevels && !customLevels) throw Error('customLevels is required if useOnlyCustomLevels is set true')
|
||||
|
||||
@ -218,7 +218,7 @@ if (process.title !== 'browser') {
|
||||
}
|
||||
|
||||
test('child does not overwrite parent serializers', ({ end, is }) => {
|
||||
var c = 0
|
||||
let c = 0
|
||||
const parent = pino({
|
||||
serializers: parentSerializers,
|
||||
browser: {
|
||||
@ -301,7 +301,7 @@ test('non overridden serializers are available in the children', ({ end, is }) =
|
||||
onlyChild: () => 'child'
|
||||
}
|
||||
|
||||
var c = 0
|
||||
let c = 0
|
||||
|
||||
const parent = pino({
|
||||
serializers: pSerializers,
|
||||
|
||||
@ -17,7 +17,7 @@ test('throws if transmit object does not have send function', ({ end, throws })
|
||||
})
|
||||
|
||||
test('calls send function after write', ({ end, is }) => {
|
||||
var c = 0
|
||||
let c = 0
|
||||
const logger = pino({
|
||||
browser: {
|
||||
write: () => {
|
||||
@ -124,7 +124,7 @@ test('passes send function message objects in logEvent object when asObject is s
|
||||
})
|
||||
|
||||
test('supplies a timestamp (ts) in logEvent object which is exactly the same as the `time` property in asObject mode', ({ end, is }) => {
|
||||
var expected
|
||||
let expected
|
||||
const logger = pino({
|
||||
browser: {
|
||||
asObject: true, // implicit because `write`, but just to be explicit
|
||||
@ -188,7 +188,7 @@ test('passes send function level:{label, value} via logEvent object', ({ end, is
|
||||
})
|
||||
|
||||
test('calls send function according to transmit.level', ({ end, is }) => {
|
||||
var c = 0
|
||||
let c = 0
|
||||
const logger = pino({
|
||||
browser: {
|
||||
write: noop,
|
||||
@ -209,7 +209,7 @@ test('calls send function according to transmit.level', ({ end, is }) => {
|
||||
})
|
||||
|
||||
test('transmit.level defaults to logger level', ({ end, is }) => {
|
||||
var c = 0
|
||||
let c = 0
|
||||
const logger = pino({
|
||||
level: 'error',
|
||||
browser: {
|
||||
@ -230,7 +230,7 @@ test('transmit.level defaults to logger level', ({ end, is }) => {
|
||||
})
|
||||
|
||||
test('transmit.level is effective even if lower than logger level', ({ end, is }) => {
|
||||
var c = 0
|
||||
let c = 0
|
||||
const logger = pino({
|
||||
level: 'error',
|
||||
browser: {
|
||||
@ -312,8 +312,8 @@ test('applies all serializers to messages and bindings (serialize:true)', ({ end
|
||||
})
|
||||
|
||||
test('extracts correct bindings and raw messages over multiple transmits', ({ end, same, is }) => {
|
||||
var messages = null
|
||||
var bindings = null
|
||||
let messages = null
|
||||
let bindings = null
|
||||
|
||||
const logger = pino({
|
||||
browser: {
|
||||
|
||||
@ -97,7 +97,8 @@ test('exposes levels object', ({ end, same }) => {
|
||||
test('exposes faux stdSerializers', ({ end, ok, same }) => {
|
||||
ok(pino.stdSerializers)
|
||||
// make sure faux stdSerializers match pino-std-serializers
|
||||
for (const serializer in pinoStdSerializers) {
|
||||
/* eslint no-var: off */
|
||||
for (var serializer in pinoStdSerializers) {
|
||||
ok(pino.stdSerializers[serializer], `pino.stdSerializers.${serializer}`)
|
||||
}
|
||||
// confirm faux methods return empty objects
|
||||
@ -133,7 +134,7 @@ absentConsoleMethodTest('trace', 'log')
|
||||
// do not run this with airtap
|
||||
if (process.title !== 'browser') {
|
||||
test('in absence of console, log methods become noops', ({ end, ok }) => {
|
||||
var console = global.console
|
||||
const console = global.console
|
||||
delete global.console
|
||||
const instance = fresh('../browser')()
|
||||
global.console = console
|
||||
@ -149,7 +150,7 @@ if (process.title !== 'browser') {
|
||||
}
|
||||
|
||||
test('opts.browser.asObject logs pino-like object to console', ({ end, ok, is }) => {
|
||||
var info = console.info
|
||||
const info = console.info
|
||||
console.info = function (o) {
|
||||
is(o.level, 30)
|
||||
is(o.msg, 'test')
|
||||
@ -388,7 +389,7 @@ test('opts.browser.asObject defensively mitigates naughty numbers', ({ end, pass
|
||||
})
|
||||
|
||||
test('opts.browser.write obj falls back to console where a method is not supplied', ({ end, ok, is }) => {
|
||||
var info = console.info
|
||||
const info = console.info
|
||||
console.info = (o) => {
|
||||
is(o.level, 30)
|
||||
is(o.msg, 'test')
|
||||
@ -414,7 +415,7 @@ test('opts.browser.write obj falls back to console where a method is not supplie
|
||||
|
||||
function levelTest (name) {
|
||||
test(name + ' logs', ({ end, is }) => {
|
||||
var msg = 'hello world'
|
||||
const msg = 'hello world'
|
||||
sink(name, (args) => {
|
||||
is(args[0], msg)
|
||||
end()
|
||||
@ -423,7 +424,7 @@ function levelTest (name) {
|
||||
})
|
||||
|
||||
test('passing objects at level ' + name, ({ end, is }) => {
|
||||
var msg = { hello: 'world' }
|
||||
const msg = { hello: 'world' }
|
||||
sink(name, (args) => {
|
||||
is(args[0], msg)
|
||||
end()
|
||||
@ -432,8 +433,8 @@ function levelTest (name) {
|
||||
})
|
||||
|
||||
test('passing an object and a string at level ' + name, ({ end, is }) => {
|
||||
var a = { hello: 'world' }
|
||||
var b = 'a string'
|
||||
const a = { hello: 'world' }
|
||||
const b = 'a string'
|
||||
sink(name, (args) => {
|
||||
is(args[0], a)
|
||||
is(args[1], b)
|
||||
@ -452,7 +453,7 @@ function levelTest (name) {
|
||||
})
|
||||
|
||||
test('passing error at level ' + name, ({ end, is }) => {
|
||||
var err = new Error('myerror')
|
||||
const err = new Error('myerror')
|
||||
sink(name, (args) => {
|
||||
is(args[0], err)
|
||||
end()
|
||||
@ -462,7 +463,7 @@ function levelTest (name) {
|
||||
|
||||
test('passing error with a serializer at level ' + name, ({ end, is }) => {
|
||||
// in browser - should have no effect (should not crash)
|
||||
var err = new Error('myerror')
|
||||
const err = new Error('myerror')
|
||||
sink(name, (args) => {
|
||||
is(args[0].err, err)
|
||||
end()
|
||||
@ -477,8 +478,8 @@ function levelTest (name) {
|
||||
})
|
||||
|
||||
test('child logger for level ' + name, ({ end, is }) => {
|
||||
var msg = 'hello world'
|
||||
var parent = { hello: 'world' }
|
||||
const msg = 'hello world'
|
||||
const parent = { hello: 'world' }
|
||||
sink(name, (args) => {
|
||||
is(args[0], parent)
|
||||
is(args[1], msg)
|
||||
@ -490,9 +491,9 @@ function levelTest (name) {
|
||||
})
|
||||
|
||||
test('child-child logger for level ' + name, ({ end, is }) => {
|
||||
var msg = 'hello world'
|
||||
var grandParent = { hello: 'world' }
|
||||
var parent = { hello: 'you' }
|
||||
const msg = 'hello world'
|
||||
const grandParent = { hello: 'world' }
|
||||
const parent = { hello: 'you' }
|
||||
sink(name, (args) => {
|
||||
is(args[0], grandParent)
|
||||
is(args[1], parent)
|
||||
@ -519,7 +520,7 @@ function consoleMethodTest (level, method) {
|
||||
|
||||
function absentConsoleMethodTest (method, fallback) {
|
||||
test('in absence of console.' + method + ', console.' + fallback + ' is used', ({ end, is }) => {
|
||||
var fn = console[method]
|
||||
const fn = console[method]
|
||||
console[method] = undefined
|
||||
sink(fallback, function (args) {
|
||||
is(args[0], 'test')
|
||||
@ -533,13 +534,13 @@ function absentConsoleMethodTest (method, fallback) {
|
||||
|
||||
function isFunc (fn) { return typeof fn === 'function' }
|
||||
function fnName (fn) {
|
||||
var rx = /^\s*function\s*([^(]*)/i
|
||||
var match = rx.exec(fn)
|
||||
const rx = /^\s*function\s*([^(]*)/i
|
||||
const match = rx.exec(fn)
|
||||
return match && match[1]
|
||||
}
|
||||
function sink (method, fn) {
|
||||
if (method === 'fatal') method = 'error'
|
||||
var orig = console[method]
|
||||
const orig = console[method]
|
||||
console[method] = function () {
|
||||
console[method] = orig
|
||||
fn(Array.prototype.slice.call(arguments))
|
||||
|
||||
@ -123,9 +123,9 @@ test('an error with statusCode property is not confused for a http response', as
|
||||
|
||||
test('stack is omitted if it is not set on err', t => {
|
||||
t.plan(2)
|
||||
var err = new Error('myerror')
|
||||
const err = new Error('myerror')
|
||||
delete err.stack
|
||||
var instance = pino(sink(function (chunk, enc, cb) {
|
||||
const 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.equal(chunk.hasOwnProperty('stack'), false)
|
||||
@ -138,9 +138,9 @@ test('stack is omitted if it is not set on err', t => {
|
||||
|
||||
test('stack is rendered as any other property if it\'s not a string', t => {
|
||||
t.plan(3)
|
||||
var err = new Error('myerror')
|
||||
const err = new Error('myerror')
|
||||
err.stack = null
|
||||
var instance = pino(sink(function (chunk, enc, cb) {
|
||||
const 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.equal(chunk.hasOwnProperty('stack'), true)
|
||||
|
||||
@ -8,7 +8,7 @@ const { once } = require('./helper')
|
||||
|
||||
// https://github.com/pinojs/pino/issues/542
|
||||
test('pino.destination log everything when calling process.exit(0)', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'destination-exit.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -23,7 +23,7 @@ test('pino.destination log everything when calling process.exit(0)', async ({ is
|
||||
})
|
||||
|
||||
test('pino with no args log everything when calling process.exit(0)', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'default-exit.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -38,7 +38,7 @@ test('pino with no args log everything when calling process.exit(0)', async ({ i
|
||||
})
|
||||
|
||||
test('sync false does not log everything when calling process.exit(0)', async ({ is }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'syncfalse-exit.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -53,7 +53,7 @@ test('sync false does not log everything when calling process.exit(0)', async ({
|
||||
})
|
||||
|
||||
test('sync false logs everything when calling flushSync', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'syncfalse-flush-exit.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
|
||||
@ -44,7 +44,7 @@ test('returns an exit listener function', async ({ is }) => {
|
||||
|
||||
test('listener function immediately sync flushes when fired (sync false)', async ({ pass, fail }) => {
|
||||
const dest = pino.destination({ dest: getPathToNull(), sync: false })
|
||||
var passed = false
|
||||
let passed = false
|
||||
dest.flushSync = () => {
|
||||
passed = true
|
||||
pass('flushSync called')
|
||||
@ -56,7 +56,7 @@ test('listener function immediately sync flushes when fired (sync false)', async
|
||||
|
||||
test('listener function immediately sync flushes when fired (sync true)', async ({ pass, fail }) => {
|
||||
const dest = pino.destination({ dest: getPathToNull(), sync: true })
|
||||
var passed = false
|
||||
let passed = false
|
||||
dest.flushSync = () => {
|
||||
passed = true
|
||||
pass('flushSync called')
|
||||
@ -75,7 +75,7 @@ test('swallows the non-ready error', async ({ doesNotThrow }) => {
|
||||
|
||||
test('listener function triggers handler function parameter', async ({ pass, fail }) => {
|
||||
const dest = pino.destination({ dest: getPathToNull(), sync: false })
|
||||
var passed = false
|
||||
let passed = false
|
||||
pino.final(pino(dest), () => {
|
||||
passed = true
|
||||
pass('handler function triggered')
|
||||
@ -140,8 +140,8 @@ test('returns a specialized final logger instance if no handler is passed', asyn
|
||||
test('final logger instances synchronously flush after a log method call', async ({ pass, fail, error }) => {
|
||||
const dest = pino.destination({ dest: getPathToNull(), sync: false })
|
||||
const logger = pino(dest)
|
||||
var passed = false
|
||||
var count = 0
|
||||
let passed = false
|
||||
let count = 0
|
||||
dest.flushSync = () => {
|
||||
count++
|
||||
if (count === 2) {
|
||||
@ -164,8 +164,8 @@ test('also instruments custom log methods', async ({ pass, fail, error }) => {
|
||||
foo: 35
|
||||
}
|
||||
}, dest)
|
||||
var passed = false
|
||||
var count = 0
|
||||
let passed = false
|
||||
let count = 0
|
||||
dest.flushSync = () => {
|
||||
count++
|
||||
if (count === 2) {
|
||||
|
||||
3
test/fixtures/broken-pipe/syncfalse.js
vendored
3
test/fixtures/broken-pipe/syncfalse.js
vendored
@ -7,6 +7,7 @@ require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
const pino = require('../../..')
|
||||
const logger = pino(pino.destination({ sync: false }))
|
||||
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
/* eslint no-var: off */
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
logger.info('hello world')
|
||||
}
|
||||
|
||||
4
test/fixtures/default-exit.js
vendored
4
test/fixtures/default-exit.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../'))
|
||||
var logger = pino()
|
||||
const pino = require(require.resolve('./../../'))
|
||||
const logger = pino()
|
||||
logger.info('hello')
|
||||
logger.info('world')
|
||||
process.exit(0)
|
||||
|
||||
4
test/fixtures/destination-exit.js
vendored
4
test/fixtures/destination-exit.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../'))
|
||||
var logger = pino({}, pino.destination(1))
|
||||
const pino = require(require.resolve('./../../'))
|
||||
const logger = pino({}, pino.destination(1))
|
||||
logger.info('hello')
|
||||
logger.info('world')
|
||||
process.exit(0)
|
||||
|
||||
4
test/fixtures/pretty/basic.js
vendored
4
test/fixtures/pretty/basic.js
vendored
@ -1,6 +1,6 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: true })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: true })
|
||||
log.info('h')
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
prettyPrint: true,
|
||||
serializers: {
|
||||
a (num) {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: true }).child({ foo: 123 })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: true }).child({ foo: 123 })
|
||||
log.info('before')
|
||||
log.setBindings({ foo: 456, bar: 789 })
|
||||
log.info('after')
|
||||
|
||||
4
test/fixtures/pretty/child.js
vendored
4
test/fixtures/pretty/child.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: true }).child({ a: 1 })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: true }).child({ a: 1 })
|
||||
log.info('h')
|
||||
log.child({ b: 2 }).info('h3')
|
||||
setTimeout(() => log.info('h2'), 200)
|
||||
|
||||
4
test/fixtures/pretty/custom-time-label.js
vendored
4
test/fixtures/pretty/custom-time-label.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
timestamp: () => ',"custom-time-label":"test"',
|
||||
prettyPrint: true
|
||||
})
|
||||
|
||||
4
test/fixtures/pretty/custom-time.js
vendored
4
test/fixtures/pretty/custom-time.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
timestamp: () => ',"time":"test"',
|
||||
prettyPrint: true
|
||||
})
|
||||
|
||||
4
test/fixtures/pretty/dateformat.js
vendored
4
test/fixtures/pretty/dateformat.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
prettyPrint: {
|
||||
translateTime: true
|
||||
}
|
||||
|
||||
6
test/fixtures/pretty/error-props.js
vendored
6
test/fixtures/pretty/error-props.js
vendored
@ -1,9 +1,9 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
prettyPrint: { errorProps: 'code,errno' }
|
||||
})
|
||||
var err = Object.assign(new Error('kaboom'), { code: 'ENOENT', errno: 1 })
|
||||
const err = Object.assign(new Error('kaboom'), { code: 'ENOENT', errno: 1 })
|
||||
log.error(err)
|
||||
|
||||
4
test/fixtures/pretty/error.js
vendored
4
test/fixtures/pretty/error.js
vendored
@ -1,7 +1,7 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: true })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: true })
|
||||
log.error(new Error('kaboom'))
|
||||
log.error(new Error('kaboom'), 'with a message')
|
||||
|
||||
4
test/fixtures/pretty/final-no-log-before.js
vendored
4
test/fixtures/pretty/final-no-log-before.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: true })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: true })
|
||||
process.once('beforeExit', pino.final(log, (_, logger) => {
|
||||
logger.info('beforeExit')
|
||||
}))
|
||||
|
||||
4
test/fixtures/pretty/final-return.js
vendored
4
test/fixtures/pretty/final-return.js
vendored
@ -1,7 +1,7 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: true })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: true })
|
||||
log.info('h')
|
||||
pino.final(log).info('after')
|
||||
|
||||
4
test/fixtures/pretty/final.js
vendored
4
test/fixtures/pretty/final.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: true })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: true })
|
||||
log.info('h')
|
||||
process.once('beforeExit', pino.final(log, (_, logger) => {
|
||||
logger.info('beforeExit')
|
||||
|
||||
4
test/fixtures/pretty/formatters.js
vendored
4
test/fixtures/pretty/formatters.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
prettyPrint: true,
|
||||
formatters: {
|
||||
log (obj) {
|
||||
|
||||
4
test/fixtures/pretty/level-first.js
vendored
4
test/fixtures/pretty/level-first.js
vendored
@ -1,6 +1,6 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: { levelFirst: true } })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: { levelFirst: true } })
|
||||
log.info('h')
|
||||
|
||||
4
test/fixtures/pretty/no-time.js
vendored
4
test/fixtures/pretty/no-time.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
timestamp: false,
|
||||
prettyPrint: true
|
||||
})
|
||||
|
||||
4
test/fixtures/pretty/obj-msg-prop.js
vendored
4
test/fixtures/pretty/obj-msg-prop.js
vendored
@ -1,6 +1,6 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: true })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: true })
|
||||
log.info({ msg: 'hello' })
|
||||
|
||||
4
test/fixtures/pretty/pretty-factory.js
vendored
4
test/fixtures/pretty/pretty-factory.js
vendored
@ -1,6 +1,6 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: { levelFirst: true }, prettifier: require('pino-pretty') })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: { levelFirst: true }, prettifier: require('pino-pretty') })
|
||||
log.info('h')
|
||||
|
||||
4
test/fixtures/pretty/redact.js
vendored
4
test/fixtures/pretty/redact.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
prettyPrint: true,
|
||||
redact: ['foo.an']
|
||||
})
|
||||
|
||||
4
test/fixtures/pretty/serializers.js
vendored
4
test/fixtures/pretty/serializers.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
prettyPrint: true,
|
||||
serializers: {
|
||||
foo (obj) {
|
||||
|
||||
4
test/fixtures/pretty/skipped-output.js
vendored
4
test/fixtures/pretty/skipped-output.js
vendored
@ -1,8 +1,8 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({
|
||||
prettyPrint: true,
|
||||
prettifier: function () {
|
||||
return function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../../'))
|
||||
var log = pino({ prettyPrint: { suppressFlushSyncWarning: true } })
|
||||
const pino = require(require.resolve('./../../../'))
|
||||
const log = pino({ prettyPrint: { suppressFlushSyncWarning: true } })
|
||||
log.info('h')
|
||||
log.fatal('h1')
|
||||
|
||||
2
test/fixtures/stdout-hack-protection.js
vendored
2
test/fixtures/stdout-hack-protection.js
vendored
@ -7,5 +7,5 @@ process.stdout.write = function (chunk) {
|
||||
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('../../'))()
|
||||
const pino = require(require.resolve('../../'))()
|
||||
pino.info('me')
|
||||
|
||||
4
test/fixtures/syncfalse-child.js
vendored
4
test/fixtures/syncfalse-child.js
vendored
@ -1,6 +1,6 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../'))
|
||||
var asyncLogger = pino(pino.destination({ sync: false })).child({ hello: 'world' })
|
||||
const pino = require(require.resolve('./../../'))
|
||||
const asyncLogger = pino(pino.destination({ sync: false })).child({ hello: 'world' })
|
||||
pino.final(asyncLogger, (_, logger) => logger.info('h'))()
|
||||
|
||||
6
test/fixtures/syncfalse-exit.js
vendored
6
test/fixtures/syncfalse-exit.js
vendored
@ -1,9 +1,9 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../'))
|
||||
var dest = pino.destination({ dest: 1, minLength: 4096, sync: false })
|
||||
var logger = pino({}, dest)
|
||||
const pino = require(require.resolve('./../../'))
|
||||
const dest = pino.destination({ dest: 1, minLength: 4096, sync: false })
|
||||
const logger = pino({}, dest)
|
||||
logger.info('hello')
|
||||
logger.info('world')
|
||||
process.exit(0)
|
||||
|
||||
6
test/fixtures/syncfalse-flush-exit.js
vendored
6
test/fixtures/syncfalse-flush-exit.js
vendored
@ -1,9 +1,9 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../'))
|
||||
var dest = pino.destination({ dest: 1, minLength: 4096, sync: false })
|
||||
var logger = pino({}, dest)
|
||||
const pino = require(require.resolve('./../../'))
|
||||
const dest = pino.destination({ dest: 1, minLength: 4096, sync: false })
|
||||
const logger = pino({}, dest)
|
||||
logger.info('hello')
|
||||
logger.info('world')
|
||||
dest.flushSync()
|
||||
|
||||
4
test/fixtures/syncfalse.js
vendored
4
test/fixtures/syncfalse.js
vendored
@ -1,6 +1,6 @@
|
||||
global.process = { __proto__: process, pid: 123456 }
|
||||
Date.now = function () { return 1459875739796 }
|
||||
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
|
||||
var pino = require(require.resolve('./../../'))
|
||||
var asyncLogger = pino(pino.destination({ minLength: 4096, sync: false }))
|
||||
const pino = require(require.resolve('./../../'))
|
||||
const asyncLogger = pino(pino.destination({ minLength: 4096, sync: false }))
|
||||
pino.final(asyncLogger, (_, logger) => logger.info('h'))()
|
||||
|
||||
@ -11,7 +11,7 @@ const { pid } = process
|
||||
const hostname = os.hostname()
|
||||
|
||||
test('http request support', async ({ ok, same, error, teardown }) => {
|
||||
var originalReq
|
||||
let originalReq
|
||||
const instance = pino(sink((chunk, enc) => {
|
||||
ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
|
||||
delete chunk.time
|
||||
@ -45,7 +45,7 @@ test('http request support', async ({ ok, same, error, teardown }) => {
|
||||
})
|
||||
|
||||
test('http request support via serializer', async ({ ok, same, error, teardown }) => {
|
||||
var originalReq
|
||||
let originalReq
|
||||
const instance = pino({
|
||||
serializers: {
|
||||
req: pino.stdSerializers.req
|
||||
@ -85,7 +85,7 @@ test('http request support via serializer', async ({ ok, same, error, teardown }
|
||||
|
||||
// skipped because request connection is deprecated since v13, and request socket is always available
|
||||
skip('http request support via serializer without request connection', async ({ ok, same, error, teardown }) => {
|
||||
var originalReq
|
||||
let originalReq
|
||||
const instance = pino({
|
||||
serializers: {
|
||||
req: pino.stdSerializers.req
|
||||
@ -128,7 +128,7 @@ skip('http request support via serializer without request connection', async ({
|
||||
})
|
||||
|
||||
test('http response support', async ({ ok, same, error, teardown }) => {
|
||||
var originalRes
|
||||
let originalRes
|
||||
const instance = pino(sink((chunk, enc) => {
|
||||
ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
|
||||
delete chunk.time
|
||||
@ -201,7 +201,7 @@ test('http response support via a serializer', async ({ ok, same, error, teardow
|
||||
})
|
||||
|
||||
test('http request support via serializer in a child', async ({ ok, same, error, teardown }) => {
|
||||
var originalReq
|
||||
let originalReq
|
||||
const instance = pino({
|
||||
serializers: {
|
||||
req: pino.stdSerializers.req
|
||||
|
||||
@ -107,7 +107,7 @@ test('level-change event', async ({ is }) => {
|
||||
instance.removeListener('level-change', handle)
|
||||
instance.level = 'info'
|
||||
|
||||
var count = 0
|
||||
let count = 0
|
||||
|
||||
const l1 = () => count++
|
||||
const l2 = () => count++
|
||||
|
||||
@ -10,7 +10,7 @@ const pino = require('../')
|
||||
const strip = require('strip-ansi')
|
||||
|
||||
test('can be enabled via exported pino function', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'basic.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -22,7 +22,7 @@ test('can be enabled via exported pino function', async ({ isNot }) => {
|
||||
})
|
||||
|
||||
test('can be enabled via exported pino function with pretty configuration', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'level-first.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -34,7 +34,7 @@ test('can be enabled via exported pino function with pretty configuration', asyn
|
||||
})
|
||||
|
||||
test('can be enabled via exported pino function with prettifier', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'pretty-factory.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -85,7 +85,7 @@ test('can send pretty print to custom stream', async ({ is }) => {
|
||||
})
|
||||
|
||||
test('ignores `undefined` from prettifier', async ({ is }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'skipped-output.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc) => {
|
||||
@ -97,7 +97,7 @@ test('ignores `undefined` from prettifier', async ({ is }) => {
|
||||
})
|
||||
|
||||
test('parses and outputs chindings', async ({ is, isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'child.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -113,7 +113,7 @@ test('parses and outputs chindings', async ({ is, isNot }) => {
|
||||
})
|
||||
|
||||
test('applies updated chindings', async ({ is, isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'child-with-updated-chindings.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -127,7 +127,7 @@ test('applies updated chindings', async ({ is, isNot }) => {
|
||||
})
|
||||
|
||||
test('applies formatters', async ({ is, isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'formatters.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -140,7 +140,7 @@ test('applies formatters', async ({ is, isNot }) => {
|
||||
})
|
||||
|
||||
test('parses and outputs chindings with serializer', async ({ is, isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'child-with-serializer.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -159,7 +159,7 @@ test('parses and outputs chindings with serializer', async ({ is, isNot }) => {
|
||||
})
|
||||
|
||||
test('applies serializers', async ({ is, isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'serializers.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -172,7 +172,7 @@ test('applies serializers', async ({ is, isNot }) => {
|
||||
})
|
||||
|
||||
test('applies redaction rules', async ({ is, isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'redact.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -186,7 +186,7 @@ test('applies redaction rules', async ({ is, isNot }) => {
|
||||
})
|
||||
|
||||
test('dateformat', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'dateformat.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -198,7 +198,7 @@ test('dateformat', async ({ isNot }) => {
|
||||
})
|
||||
|
||||
test('without timestamp', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'no-time.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -210,7 +210,7 @@ test('without timestamp', async ({ isNot }) => {
|
||||
})
|
||||
|
||||
test('with custom timestamp', async ({ is }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'custom-time.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -222,7 +222,7 @@ test('with custom timestamp', async ({ is }) => {
|
||||
})
|
||||
|
||||
test('with custom timestamp label', async ({ is }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'custom-time-label.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -234,7 +234,7 @@ test('with custom timestamp label', async ({ is }) => {
|
||||
})
|
||||
|
||||
test('errors', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'error.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -248,7 +248,7 @@ test('errors', async ({ isNot }) => {
|
||||
})
|
||||
|
||||
test('errors with props', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'error-props.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -263,7 +263,7 @@ test('errors with props', async ({ isNot }) => {
|
||||
})
|
||||
|
||||
test('final works with pretty', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'final.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -276,7 +276,7 @@ test('final works with pretty', async ({ isNot }) => {
|
||||
})
|
||||
|
||||
test('final works when returning a logger', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'final-return.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -289,7 +289,7 @@ test('final works when returning a logger', async ({ isNot }) => {
|
||||
})
|
||||
|
||||
test('final works without prior logging', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'final-no-log-before.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -302,7 +302,7 @@ test('final works without prior logging', async ({ isNot }) => {
|
||||
})
|
||||
|
||||
test('suppress flush sync warning when corresponding option is specified', async ({ isNot, is }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'suppress-flush-sync-warning.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -314,7 +314,7 @@ test('suppress flush sync warning when corresponding option is specified', async
|
||||
})
|
||||
|
||||
test('works as expected with an object with the msg prop', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'obj-msg-prop.js')])
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
|
||||
@ -7,7 +7,7 @@ const { once } = require('./helper')
|
||||
const writer = require('flush-write-stream')
|
||||
|
||||
test('do not use SonicBoom is someone tampered with process.stdout.write', async ({ isNot }) => {
|
||||
var actual = ''
|
||||
let actual = ''
|
||||
const child = fork(join(__dirname, 'fixtures', 'stdout-hack-protection.js'), { silent: true })
|
||||
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
|
||||
@ -20,8 +20,8 @@ test('asynchronous logging', async ({ is, teardown }) => {
|
||||
os.hostname = () => 'abcdefghijklmnopqr'
|
||||
delete require.cache[require.resolve('../')]
|
||||
const pino = require('../')
|
||||
var expected = ''
|
||||
var actual = ''
|
||||
let expected = ''
|
||||
let actual = ''
|
||||
const normal = pino(writer((s, enc, cb) => {
|
||||
expected += s
|
||||
cb()
|
||||
@ -33,14 +33,14 @@ test('asynchronous logging', async ({ is, teardown }) => {
|
||||
}
|
||||
const asyncLogger = pino(dest)
|
||||
|
||||
var i = 44
|
||||
let i = 44
|
||||
while (i--) {
|
||||
normal.info('h')
|
||||
asyncLogger.info('h')
|
||||
}
|
||||
|
||||
var expected2 = expected.split('\n')[0]
|
||||
var actual2 = ''
|
||||
const expected2 = expected.split('\n')[0]
|
||||
let actual2 = ''
|
||||
|
||||
const child = fork(join(__dirname, '/fixtures/syncfalse.js'), { silent: true })
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -74,8 +74,8 @@ test('sync false with child', async ({ is, teardown }) => {
|
||||
}
|
||||
delete require.cache[require.resolve('../')]
|
||||
const pino = require('../')
|
||||
var expected = ''
|
||||
var actual = ''
|
||||
let expected = ''
|
||||
let actual = ''
|
||||
const normal = pino(writer((s, enc, cb) => {
|
||||
expected += s
|
||||
cb()
|
||||
@ -85,7 +85,7 @@ test('sync false with child', async ({ is, teardown }) => {
|
||||
dest.write = function (s) { actual += s }
|
||||
const asyncLogger = pino(dest).child({ hello: 'world' })
|
||||
|
||||
var i = 500
|
||||
let i = 500
|
||||
while (i--) {
|
||||
normal.info('h')
|
||||
asyncLogger.info('h')
|
||||
@ -93,8 +93,8 @@ test('sync false with child', async ({ is, teardown }) => {
|
||||
|
||||
asyncLogger.flush()
|
||||
|
||||
var expected2 = expected.split('\n')[0]
|
||||
var actual2 = ''
|
||||
const expected2 = expected.split('\n')[0]
|
||||
let actual2 = ''
|
||||
|
||||
const child = fork(join(__dirname, '/fixtures/syncfalse-child.js'), { silent: true })
|
||||
child.stdout.pipe(writer((s, enc, cb) => {
|
||||
@ -120,7 +120,7 @@ test('throw an error if extreme is passed', async ({ throws }) => {
|
||||
})
|
||||
|
||||
test('flush does nothing with sync true (default)', async () => {
|
||||
var instance = require('..')()
|
||||
const instance = require('..')()
|
||||
instance.flush()
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user