pino-multi-stream
Advanced tools
Comparing version 5.3.0 to 6.0.0
@@ -49,3 +49,3 @@ 'use strict' | ||
function benchBunyanTen (cb) { | ||
for (var i = 0; i < max; i++) { | ||
for (let i = 0; i < max; i++) { | ||
blogTen.info('hello world') | ||
@@ -60,3 +60,3 @@ blogTen.debug('hello world') | ||
function benchPinoMSTen (cb) { | ||
for (var i = 0; i < max; i++) { | ||
for (let i = 0; i < max; i++) { | ||
pinomsTen.info('hello world') | ||
@@ -71,3 +71,3 @@ pinomsTen.debug('hello world') | ||
function benchBunyanFour (cb) { | ||
for (var i = 0; i < max; i++) { | ||
for (let i = 0; i < max; i++) { | ||
blogFour.info('hello world') | ||
@@ -80,3 +80,3 @@ blogFour.debug('hello world') | ||
function benchPinoMSFour (cb) { | ||
for (var i = 0; i < max; i++) { | ||
for (let i = 0; i < max; i++) { | ||
pinomsFour.info('hello world') | ||
@@ -89,3 +89,3 @@ pinomsFour.debug('hello world') | ||
function benchBunyanOne (cb) { | ||
for (var i = 0; i < max; i++) { | ||
for (let i = 0; i < max; i++) { | ||
blogOne.info('hello world') | ||
@@ -96,3 +96,3 @@ } | ||
function benchPinoMSOne (cb) { | ||
for (var i = 0; i < max; i++) { | ||
for (let i = 0; i < max; i++) { | ||
pinomsOne.info('hello world') | ||
@@ -99,0 +99,0 @@ } |
12
index.js
@@ -5,3 +5,2 @@ 'use strict' | ||
const getPrettyStream = require('pino/lib/tools').getPrettyStream | ||
const multistream = require('./multistream') | ||
const { | ||
@@ -28,6 +27,6 @@ streamSym, | ||
if (Object.prototype.hasOwnProperty.call(iopts, 'streams') === true) { | ||
return fixLevel(pino(toPino, multistream(iopts.streams, opts))) | ||
return fixLevel(pino(toPino, pino.multistream(iopts.streams, opts))) | ||
} | ||
return fixLevel(pino(toPino, multistream({ stream: iopts.stream, level: iopts.level }, opts))) | ||
return fixLevel(pino(toPino, pino.multistream({ stream: iopts.stream, level: iopts.level }, opts))) | ||
@@ -38,6 +37,6 @@ function fixLevel (pino) { | ||
// internal knowledge dependency | ||
var setLevel = pino[setLevelSym] | ||
const setLevel = pino[setLevelSym] | ||
pino[setLevelSym] = function (val) { | ||
var prev = this[levelValSym] | ||
const prev = this[levelValSym] | ||
@@ -61,3 +60,3 @@ // needed to support bunyan .level() | ||
get: function () { | ||
var that = this | ||
const that = this | ||
return function (val) { | ||
@@ -84,3 +83,2 @@ if (val !== undefined) { | ||
Object.assign(pinoMultiStream, pino) | ||
pinoMultiStream.multistream = multistream | ||
pinoMultiStream.prettyStream = (args = {}) => { | ||
@@ -87,0 +85,0 @@ const prettyPrint = args.opts || args.prettyPrint |
{ | ||
"name": "pino-multi-stream", | ||
"version": "5.3.0", | ||
"version": "6.0.0", | ||
"description": "A wrapper for the Pino logger that provides Bunyan's multipe destination stream API", | ||
@@ -32,13 +32,13 @@ "main": "index.js", | ||
"fastbench": "^1.0.1", | ||
"flush-write-stream": "^1.1.1", | ||
"pino-pretty": "^4.0.2", | ||
"flush-write-stream": "^2.0.0", | ||
"pino-pretty": "^7.0.0", | ||
"pre-commit": "^1.2.2", | ||
"split2": "^3.1.1", | ||
"standard": "^14.3.3", | ||
"standard": "^16.0.3", | ||
"strip-ansi": "^6.0.0", | ||
"tap": "^14.0.0" | ||
"tap": "^15.0.0" | ||
}, | ||
"dependencies": { | ||
"pino": "^6.0.0" | ||
"pino": "^7.0.0" | ||
} | ||
} |
@@ -24,3 +24,3 @@ # pino-multi-stream ![CI](https://github.com/pinojs/pino-multi-stream/workflows/CI/badge.svg) | ||
For Pino v5+ | ||
For Pino v7+ | ||
@@ -31,6 +31,6 @@ ```js | ||
For Pino v4 and below: | ||
For Pino v5 and v6 | ||
```js | ||
npm install -s pino-multi-stream@legacy #v3 pino-multi-stream line | ||
npm install -s pino-multi-stream@legacy | ||
``` | ||
@@ -95,67 +95,2 @@ | ||
### pinoms.multistream(streams, opts) | ||
Manually create a single `multistream` as used internally by the | ||
wrapper: | ||
```js | ||
var fs = require('fs') | ||
var pino = require('pino') | ||
var multistream = require('pino-multi-stream').multistream | ||
var streams = [ | ||
{stream: fs.createWriteStream('/tmp/info.stream.out')}, | ||
{level: 'debug', stream: fs.createWriteStream('/tmp/debug.stream.out')}, | ||
{level: 'fatal', stream: fs.createWriteStream('/tmp/fatal.stream.out')} | ||
] | ||
var log = pino({ | ||
level: 'debug' // this MUST be set at the lowest level of the | ||
// destinations | ||
}, multistream(streams)) | ||
log.debug('this will be written to /tmp/debug.stream.out') | ||
log.info('this will be written to /tmp/debug.stream.out and /tmp/info.stream.out') | ||
log.fatal('this will be written to /tmp/debug.stream.out, /tmp/info.stream.out and /tmp/fatal.stream.out') | ||
``` | ||
`opts` multistream options object. Available options are: | ||
* `levels`: Pass custom log level definitions to the instance as an object. | ||
+ `dedupe`: Set this to `true` to send logs only to the stream with the higher level. Default: `false` | ||
`dedupe` flag can be useful for example when using pino-multi-stream to redirect `error` logs to `process.stderr` and others to `process.stdout`: | ||
```js | ||
var pino = require('pino') | ||
var multistream = require('pino-multi-stream').multistream | ||
var streams = [ | ||
{stream: process.stdout}, | ||
{level: 'error', stream: process.stderr}, | ||
] | ||
var opts = { | ||
levels: { | ||
silent: Infinity, | ||
fatal: 60, | ||
error: 50, | ||
warn: 50, | ||
info: 30, | ||
debug: 20, | ||
trace: 10 | ||
}, | ||
dedupe: true, | ||
} | ||
var log = pino({ | ||
level: 'debug' // this MUST be set at the lowest level of the | ||
// destinations | ||
}, multistream(streams, opts)) | ||
log.debug('this will be written ONLY to process.stdout') | ||
log.info('this will be written ONLY to process.stdout') | ||
log.error('this will be written ONLY to process.stderr') | ||
log.fatal('this will be written ONLY to process.stderr') | ||
``` | ||
### pinoms.level set accessor | ||
@@ -177,4 +112,2 @@ | ||
_Note_: after 4.1.0 this `pino-multi-stream` function was changed according to that of `pino`, and after 4.2.0 its API (names of parameters and their options) are in conformity with API of `pino`/`pino-pretty`, as it is presented [here](https://getpino.io/#/docs/pretty). Those changes are related to pretty-printing options only. | ||
Manually create an output stream with a prettifier applied. | ||
@@ -181,0 +114,0 @@ |
'use strict' | ||
var test = require('tap').test | ||
var os = require('os') | ||
var pino = require('../') | ||
const test = require('tap').test | ||
const os = require('os') | ||
const pino = require('../') | ||
var sink = require('./helper').sink | ||
var check = require('./helper').check | ||
const sink = require('./helper').sink | ||
const check = require('./helper').check | ||
var pid = process.pid | ||
var hostname = os.hostname() | ||
const pid = process.pid | ||
const hostname = os.hostname() | ||
@@ -16,3 +16,3 @@ function levelTest (name, level) { | ||
t.plan(3) | ||
var instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
const instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
check(t, chunk, level, 'hello world') | ||
@@ -28,3 +28,3 @@ })) | ||
t.plan(3) | ||
var instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
const instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
check(t, chunk, level, 'hello world') | ||
@@ -40,6 +40,6 @@ })) | ||
t.plan(3) | ||
var instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
const instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()') | ||
delete chunk.time | ||
t.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
@@ -59,6 +59,6 @@ hostname: hostname, | ||
t.plan(3) | ||
var instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
const instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()') | ||
delete chunk.time | ||
t.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
@@ -79,3 +79,3 @@ hostname: hostname, | ||
t.plan(3) | ||
var instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
const instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
check(t, chunk, level, 'hello 42') | ||
@@ -91,4 +91,4 @@ })) | ||
t.plan(3) | ||
var err = new Error('myerror') | ||
var instance = pino({ | ||
const err = new Error('myerror') | ||
const instance = pino({ | ||
bunyan: true, | ||
@@ -101,6 +101,7 @@ serializers: { | ||
delete chunk.time | ||
t.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
msg: 'myerror', | ||
err: { | ||
@@ -122,6 +123,6 @@ type: 'Error', | ||
t.plan(3) | ||
var instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
const instance = pino({ bunyan: true }, sink(function (chunk, enc, cb) { | ||
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()') | ||
delete chunk.time | ||
t.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
@@ -136,3 +137,3 @@ hostname: hostname, | ||
instance.level(name) | ||
var child = instance.child({ | ||
const child = instance.child({ | ||
hello: 'world' | ||
@@ -139,0 +140,0 @@ }) |
'use strict' | ||
var writeStream = require('flush-write-stream') | ||
var split = require('split2') | ||
var os = require('os') | ||
var pid = process.pid | ||
var hostname = os.hostname() | ||
const writeStream = require('flush-write-stream') | ||
const split = require('split2') | ||
const os = require('os') | ||
const pid = process.pid | ||
const hostname = os.hostname() | ||
function sink (func) { | ||
var result = split(JSON.parse) | ||
const result = split(JSON.parse) | ||
result.pipe(writeStream.obj(func)) | ||
@@ -18,3 +18,3 @@ return result | ||
delete chunk.time | ||
t.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
@@ -21,0 +21,0 @@ hostname: hostname, |
'use strict' | ||
var test = require('tap').test | ||
var os = require('os') | ||
var pino = require('../') | ||
const test = require('tap').test | ||
const os = require('os') | ||
const pino = require('../') | ||
var sink = require('./helper').sink | ||
var check = require('./helper').check | ||
const sink = require('./helper').sink | ||
const check = require('./helper').check | ||
var pid = process.pid | ||
var hostname = os.hostname() | ||
const pid = process.pid | ||
const hostname = os.hostname() | ||
@@ -16,3 +16,3 @@ function levelTest (name, level) { | ||
t.plan(2) | ||
var instance = pino(sink(function (chunk, enc, cb) { | ||
const instance = pino(sink(function (chunk, enc, cb) { | ||
check(t, chunk, level, 'hello world') | ||
@@ -27,6 +27,6 @@ })) | ||
t.plan(2) | ||
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.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
@@ -45,6 +45,6 @@ hostname: hostname, | ||
t.plan(2) | ||
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.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
@@ -64,3 +64,3 @@ hostname: hostname, | ||
t.plan(2) | ||
var instance = pino(sink(function (chunk, enc, cb) { | ||
const instance = pino(sink(function (chunk, enc, cb) { | ||
check(t, chunk, level, 'hello 42') | ||
@@ -75,4 +75,4 @@ })) | ||
t.plan(2) | ||
var err = new Error('myerror') | ||
var instance = pino({ | ||
const err = new Error('myerror') | ||
const instance = pino({ | ||
serializers: { | ||
@@ -84,6 +84,7 @@ err: pino.stdSerializers.err | ||
delete chunk.time | ||
t.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
msg: 'myerror', | ||
err: { | ||
@@ -104,6 +105,6 @@ type: 'Error', | ||
t.plan(2) | ||
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.deepEqual(chunk, { | ||
t.same(chunk, { | ||
pid: pid, | ||
@@ -118,3 +119,3 @@ hostname: hostname, | ||
instance.level = name | ||
var child = instance.child({ | ||
const child = instance.child({ | ||
hello: 'world' | ||
@@ -126,3 +127,3 @@ }) | ||
test('child logger for level ' + name + ' does not change parent level', function (t) { | ||
var instance = pino({ | ||
const instance = pino({ | ||
customLevels: { | ||
@@ -137,3 +138,3 @@ buu: level + 1 | ||
var child = instance.child({ | ||
const child = instance.child({ | ||
hello: 'world' | ||
@@ -140,0 +141,0 @@ }) |
'use strict' | ||
var writeStream = require('flush-write-stream') | ||
var pino = require('pino') | ||
var test = require('tap').test | ||
var pinoms = require('../') | ||
var { Writable } = require('stream') | ||
var strip = require('strip-ansi') | ||
const writeStream = require('flush-write-stream') | ||
const pino = require('pino') | ||
const test = require('tap').test | ||
const pinoms = require('../') | ||
const { Writable } = require('stream') | ||
const strip = require('strip-ansi') | ||
test('sends to multiple streams', function (t) { | ||
var messageCount = 0 | ||
var stream = writeStream(function (data, enc, cb) { | ||
let messageCount = 0 | ||
const stream = writeStream(function (data, enc, cb) { | ||
messageCount += 1 | ||
cb() | ||
}) | ||
var streams = [ | ||
const streams = [ | ||
{ stream: stream }, | ||
@@ -21,38 +21,38 @@ { level: 'debug', stream: stream }, | ||
] | ||
var log = pinoms({ streams: streams }) | ||
const log = pinoms({ streams: streams }) | ||
log.info('info stream') | ||
log.debug('debug stream') | ||
log.fatal('fatal stream') | ||
t.is(messageCount, 6) | ||
t.done() | ||
t.equal(messageCount, 6) | ||
t.end() | ||
}) | ||
test('level include higher levels', function (t) { | ||
var messageCount = 0 | ||
var stream = writeStream(function (data, enc, cb) { | ||
let messageCount = 0 | ||
const stream = writeStream(function (data, enc, cb) { | ||
messageCount += 1 | ||
cb() | ||
}) | ||
var log = pinoms({ streams: [{ level: 'info', stream: stream }] }) | ||
const log = pinoms({ streams: [{ level: 'info', stream: stream }] }) | ||
log.fatal('message') | ||
t.is(messageCount, 1) | ||
t.done() | ||
t.equal(messageCount, 1) | ||
t.end() | ||
}) | ||
test('supports multiple arguments', function (t) { | ||
var messages = [] | ||
var stream = writeStream(function (data, enc, cb) { | ||
const messages = [] | ||
const stream = writeStream(function (data, enc, cb) { | ||
messages.push(JSON.parse(data)) | ||
if (messages.length === 2) { | ||
var msg1 = messages[0] | ||
t.is(msg1.msg, 'foo bar baz foobar') | ||
const msg1 = messages[0] | ||
t.equal(msg1.msg, 'foo bar baz foobar') | ||
var msg2 = messages[1] | ||
t.is(msg2.msg, 'foo bar baz foobar barfoo foofoo') | ||
const msg2 = messages[1] | ||
t.equal(msg2.msg, 'foo bar baz foobar barfoo foofoo') | ||
t.done() | ||
t.end() | ||
} | ||
cb() | ||
}) | ||
var log = pinoms({ streams: stream }) | ||
const log = pinoms({ streams: stream }) | ||
log.info('%s %s %s %s', 'foo', 'bar', 'baz', 'foobar') // apply not invoked | ||
@@ -63,13 +63,13 @@ log.info('%s %s %s %s %s %s', 'foo', 'bar', 'baz', 'foobar', 'barfoo', 'foofoo') // apply invoked | ||
test('supports children', function (t) { | ||
var stream = writeStream(function (data, enc, cb) { | ||
var input = JSON.parse(data) | ||
t.is(input.msg, 'child stream') | ||
t.is(input.child, 'one') | ||
t.done() | ||
const stream = writeStream(function (data, enc, cb) { | ||
const input = JSON.parse(data) | ||
t.equal(input.msg, 'child stream') | ||
t.equal(input.child, 'one') | ||
t.end() | ||
cb() | ||
}) | ||
var streams = [ | ||
const streams = [ | ||
{ stream: stream } | ||
] | ||
var log = pinoms({ streams: streams }).child({ child: 'one' }) | ||
const log = pinoms({ streams: streams }).child({ child: 'one' }) | ||
log.info('child stream') | ||
@@ -79,30 +79,30 @@ }) | ||
test('supports grandchildren', function (t) { | ||
var messages = [] | ||
var stream = writeStream(function (data, enc, cb) { | ||
const messages = [] | ||
const stream = writeStream(function (data, enc, cb) { | ||
messages.push(JSON.parse(data)) | ||
if (messages.length === 3) { | ||
var msg1 = messages[0] | ||
t.is(msg1.msg, 'grandchild stream') | ||
t.is(msg1.child, 'one') | ||
t.is(msg1.grandchild, 'two') | ||
const msg1 = messages[0] | ||
t.equal(msg1.msg, 'grandchild stream') | ||
t.equal(msg1.child, 'one') | ||
t.equal(msg1.grandchild, 'two') | ||
var msg2 = messages[1] | ||
t.is(msg2.msg, 'grandchild stream') | ||
t.is(msg2.child, 'one') | ||
t.is(msg2.grandchild, 'two') | ||
const msg2 = messages[1] | ||
t.equal(msg2.msg, 'grandchild stream') | ||
t.equal(msg2.child, 'one') | ||
t.equal(msg2.grandchild, 'two') | ||
var msg3 = messages[2] | ||
t.is(msg3.msg, 'debug grandchild') | ||
t.is(msg3.child, 'one') | ||
t.is(msg3.grandchild, 'two') | ||
const msg3 = messages[2] | ||
t.equal(msg3.msg, 'debug grandchild') | ||
t.equal(msg3.child, 'one') | ||
t.equal(msg3.grandchild, 'two') | ||
t.done() | ||
t.end() | ||
} | ||
cb() | ||
}) | ||
var streams = [ | ||
const streams = [ | ||
{ stream: stream }, | ||
{ level: 'debug', stream: stream } | ||
] | ||
var log = pinoms({ streams: streams }).child({ child: 'one' }).child({ grandchild: 'two' }) | ||
const log = pinoms({ streams: streams }).child({ child: 'one' }).child({ grandchild: 'two' }) | ||
log.info('grandchild stream') | ||
@@ -113,7 +113,7 @@ log.debug('debug grandchild') | ||
test('supports custom levels', function (t) { | ||
var stream = writeStream(function (data, enc, cb) { | ||
t.is(JSON.parse(data).msg, 'bar') | ||
t.done() | ||
const stream = writeStream(function (data, enc, cb) { | ||
t.equal(JSON.parse(data).msg, 'bar') | ||
t.end() | ||
}) | ||
var log = pinoms({ | ||
const log = pinoms({ | ||
customLevels: { | ||
@@ -132,7 +132,7 @@ foo: 35 | ||
test('children support custom levels', function (t) { | ||
var stream = writeStream(function (data, enc, cb) { | ||
t.is(JSON.parse(data).msg, 'bar') | ||
t.done() | ||
const stream = writeStream(function (data, enc, cb) { | ||
t.equal(JSON.parse(data).msg, 'bar') | ||
t.end() | ||
}) | ||
var parent = pinoms({ | ||
const parent = pinoms({ | ||
customLevels: { | ||
@@ -144,6 +144,5 @@ foo: 35 | ||
stream: stream | ||
} | ||
] | ||
}] | ||
}) | ||
var child = parent.child({ child: 'yes' }) | ||
const child = parent.child({ child: 'yes' }) | ||
child.foo('bar') | ||
@@ -153,51 +152,51 @@ }) | ||
test('supports empty constructor arguments', function (t) { | ||
var log = pinoms() | ||
t.is(typeof log.info, 'function') | ||
t.done() | ||
const log = pinoms() | ||
t.equal(typeof log.info, 'function') | ||
t.end() | ||
}) | ||
test('exposes pino.destination', function (t) { | ||
t.is(pinoms.destination, pino.destination) | ||
t.done() | ||
t.equal(pinoms.destination, pino.destination) | ||
t.end() | ||
}) | ||
test('exposes pino.extreme', function (t) { | ||
t.is(pinoms.extreme, pino.extreme) | ||
t.done() | ||
t.equal(pinoms.extreme, pino.extreme) | ||
t.end() | ||
}) | ||
test('exposes pino.stdSerializers', function (t) { | ||
t.is(pinoms.stdSerializers, pino.stdSerializers) | ||
t.done() | ||
t.equal(pinoms.stdSerializers, pino.stdSerializers) | ||
t.end() | ||
}) | ||
test('exposes pino.stdTimeFunctions', function (t) { | ||
t.is(pinoms.stdTimeFunctions, pino.stdTimeFunctions) | ||
t.done() | ||
t.equal(pinoms.stdTimeFunctions, pino.stdTimeFunctions) | ||
t.end() | ||
}) | ||
test('exposes pino.LOG_VERSION', function (t) { | ||
t.is(pinoms.LOG_VERSION, pino.LOG_VERSION) | ||
t.done() | ||
t.equal(pinoms.LOG_VERSION, pino.LOG_VERSION) | ||
t.end() | ||
}) | ||
test('exposes pino.levels', function (t) { | ||
t.is(pinoms.levels, pino.levels) | ||
t.done() | ||
t.equal(pinoms.levels, pino.levels) | ||
t.end() | ||
}) | ||
test('exposes pino.symbols', function (t) { | ||
t.is(pinoms.symbols, pino.symbols) | ||
t.done() | ||
t.equal(pinoms.symbols, pino.symbols) | ||
t.end() | ||
}) | ||
test('forwards name', function (t) { | ||
var messageCount = 0 | ||
var stream = writeStream(function (data, enc, cb) { | ||
let messageCount = 0 | ||
const stream = writeStream(function (data, enc, cb) { | ||
messageCount += 1 | ||
var line = JSON.parse(data) | ||
const line = JSON.parse(data) | ||
t.equal(line.name, 'system') | ||
cb() | ||
}) | ||
var streams = [ | ||
const streams = [ | ||
{ stream: stream }, | ||
@@ -207,19 +206,19 @@ { level: 'debug', stream: stream }, | ||
] | ||
var log = pinoms({ name: 'system', streams: streams }) | ||
const log = pinoms({ name: 'system', streams: streams }) | ||
log.info('info stream') | ||
log.debug('debug stream') | ||
log.fatal('fatal stream') | ||
t.is(messageCount, 6) | ||
t.done() | ||
t.equal(messageCount, 6) | ||
t.end() | ||
}) | ||
test('forwards name via child', function (t) { | ||
var messageCount = 0 | ||
var stream = writeStream(function (data, enc, cb) { | ||
let messageCount = 0 | ||
const stream = writeStream(function (data, enc, cb) { | ||
messageCount += 1 | ||
var line = JSON.parse(data) | ||
const line = JSON.parse(data) | ||
t.equal(line.name, 'system') | ||
cb() | ||
}) | ||
var streams = [ | ||
const streams = [ | ||
{ stream: stream }, | ||
@@ -229,41 +228,41 @@ { level: 'debug', stream: stream }, | ||
] | ||
var log = pinoms({ streams: streams }).child({ name: 'system' }) | ||
const log = pinoms({ streams: streams }).child({ name: 'system' }) | ||
log.info('info stream') | ||
log.debug('debug stream') | ||
log.fatal('fatal stream') | ||
t.is(messageCount, 6) | ||
t.done() | ||
t.equal(messageCount, 6) | ||
t.end() | ||
}) | ||
test('forwards name without streams', function (t) { | ||
var messageCount = 0 | ||
var stream = writeStream(function (data, enc, cb) { | ||
let messageCount = 0 | ||
const stream = writeStream(function (data, enc, cb) { | ||
messageCount += 1 | ||
var line = JSON.parse(data) | ||
const line = JSON.parse(data) | ||
t.equal(line.name, 'system') | ||
cb() | ||
}) | ||
var log = pinoms({ name: 'system', stream: stream }) | ||
const log = pinoms({ name: 'system', stream: stream }) | ||
log.info('info stream') | ||
log.debug('debug stream') | ||
log.fatal('fatal stream') | ||
t.is(messageCount, 2) | ||
t.done() | ||
t.equal(messageCount, 2) | ||
t.end() | ||
}) | ||
test('correctly set level if passed with just one stream', function (t) { | ||
var messageCount = 0 | ||
var stream = writeStream(function (data, enc, cb) { | ||
let messageCount = 0 | ||
const stream = writeStream(function (data, enc, cb) { | ||
messageCount += 1 | ||
var line = JSON.parse(data) | ||
const line = JSON.parse(data) | ||
t.equal(line.name, 'system') | ||
cb() | ||
}) | ||
var log = pinoms({ name: 'system', level: 'debug', stream: stream }) | ||
const log = pinoms({ name: 'system', level: 'debug', stream: stream }) | ||
log.info('info stream') | ||
log.debug('debug stream') | ||
log.fatal('fatal stream') | ||
t.is(log.level, 'debug') | ||
t.is(messageCount, 3) | ||
t.done() | ||
t.equal(log.level, 'debug') | ||
t.equal(messageCount, 3) | ||
t.end() | ||
}) | ||
@@ -273,4 +272,4 @@ | ||
const prettyStream = pinoms.prettyStream() | ||
t.is(typeof prettyStream.write, 'function') | ||
t.done() | ||
t.equal(typeof prettyStream.write, 'function') | ||
t.end() | ||
}) | ||
@@ -282,4 +281,4 @@ | ||
write (formatted, enc) { | ||
t.is(/^\s*\[\d+\]\sINFO\s+\(\d+\s+on\s+.*?\):\sfoo\n$/.test(strip(formatted)), true) | ||
t.done() | ||
t.equal(/^\s*\[\d+\]\sINFO\s+\(\d+\s+on\s+.*?\):\sfoo\n$/.test(strip(formatted)), true) | ||
t.end() | ||
} | ||
@@ -301,4 +300,4 @@ }) | ||
write (formatted, enc) { | ||
t.is(formatted, 'FOO bar') | ||
t.done() | ||
t.equal(formatted, 'FOO bar') | ||
t.end() | ||
} | ||
@@ -315,4 +314,4 @@ }) | ||
write (formatted, enc) { | ||
t.is(formatted, 'INFO: foo\n') | ||
t.done() | ||
t.equal(formatted, 'INFO: foo\n') | ||
t.end() | ||
} | ||
@@ -330,4 +329,4 @@ }) | ||
write (formatted, enc) { | ||
t.is(formatted, 'INFO: foo\n') | ||
t.done() | ||
t.equal(formatted, 'INFO: foo\n') | ||
t.end() | ||
} | ||
@@ -342,8 +341,8 @@ }) | ||
test('custom levels', function (t) { | ||
var messageCount = 0 | ||
var stream = writeStream(function (data, enc, cb) { | ||
let messageCount = 0 | ||
const stream = writeStream(function (data, enc, cb) { | ||
messageCount += 1 | ||
cb() | ||
}) | ||
var streams = [ | ||
const streams = [ | ||
{ stream: stream }, | ||
@@ -353,3 +352,3 @@ { level: 15, stream: stream }, | ||
] | ||
var log = pinoms({ | ||
const log = pinoms({ | ||
level: 'debug', | ||
@@ -365,4 +364,4 @@ customLevels: { | ||
log.fatal('fatal stream') | ||
t.is(messageCount, 7) | ||
t.done() | ||
t.equal(messageCount, 7) | ||
t.end() | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1
29341
11
750
186
+ Addedon-exit-leak-free@0.2.0(transitive)
+ Addedpino@7.11.0(transitive)
+ Addedpino-std-serializers@4.0.0(transitive)
+ Addedreal-require@0.1.0(transitive)
+ Addedsafe-stable-stringify@2.5.0(transitive)
+ Addedsonic-boom@2.8.0(transitive)
+ Addedthread-stream@0.15.2(transitive)
- Removedfast-safe-stringify@2.1.1(transitive)
- Removedflatstr@1.0.12(transitive)
- Removedpino@6.14.0(transitive)
- Removedpino-std-serializers@3.2.0(transitive)
- Removedsonic-boom@1.4.1(transitive)
Updatedpino@^7.0.0