pino-multi-stream
Advanced tools
Comparing version 5.2.0 to 5.3.0
@@ -29,2 +29,3 @@ 'use strict' | ||
add, | ||
flushSync, | ||
minLevel: 0, | ||
@@ -80,2 +81,10 @@ streams: [], | ||
function flushSync () { | ||
for (const { stream } of this.streams) { | ||
if (typeof stream.flushSync === 'function') { | ||
stream.flushSync() | ||
} | ||
} | ||
} | ||
function add (dest) { | ||
@@ -121,2 +130,3 @@ const { streams } = this | ||
clone, | ||
flushSync, | ||
[metadata]: true | ||
@@ -123,0 +133,0 @@ } |
{ | ||
"name": "pino-multi-stream", | ||
"version": "5.2.0", | ||
"version": "5.3.0", | ||
"description": "A wrapper for the Pino logger that provides Bunyan's multipe destination stream API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
'use strict' | ||
var writeStream = require('flush-write-stream') | ||
const { join } = require('path') | ||
const { readFileSync } = require('fs') | ||
const os = require('os') | ||
var test = require('tap').test | ||
@@ -434,1 +437,25 @@ var pino = require('pino') | ||
}) | ||
test('flushSync', function (t) { | ||
const tmp = join( | ||
os.tmpdir(), | ||
'_' + Math.random().toString(36).substr(2, 9) | ||
) | ||
const destination = pino.destination({ dest: tmp, sync: false, minLength: 4096 }) | ||
const log = pino({ level: 'info' }, multistream([{ level: 'info', stream: destination }])) | ||
destination.on('ready', () => { | ||
log.info('foo') | ||
log.info('bar') | ||
t.is(readFileSync(tmp, { encoding: 'utf-8' }).split('\n').length - 1, 0) | ||
pino.final(log, (err, finalLogger) => { | ||
if (err) { | ||
t.fail() | ||
return t.done() | ||
} | ||
t.is(readFileSync(tmp, { encoding: 'utf-8' }).split('\n').length - 1, 2) | ||
finalLogger.info('biz') | ||
t.is(readFileSync(tmp, { encoding: 'utf-8' }).split('\n').length - 1, 3) | ||
t.done() | ||
})() | ||
}) | ||
}) |
@@ -303,3 +303,3 @@ 'use strict' | ||
write (formatted, enc) { | ||
t.is(formatted, 'INFO\t: foo\n') | ||
t.is(formatted, 'INFO: foo\n') | ||
t.done() | ||
@@ -318,3 +318,3 @@ } | ||
write (formatted, enc) { | ||
t.is(formatted, 'INFO\t: foo\n') | ||
t.is(formatted, 'INFO: foo\n') | ||
t.done() | ||
@@ -321,0 +321,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44835
1286
2