Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pino-multi-stream

Package Overview
Dependencies
Maintainers
4
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-multi-stream - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

4

index.js

@@ -27,6 +27,6 @@ 'use strict'

if (Object.prototype.hasOwnProperty.call(iopts, 'streams') === true) {
return fixLevel(pino(toPino, multistream(iopts.streams)))
return fixLevel(pino(toPino, multistream(iopts.streams, opts)))
}
return fixLevel(pino(toPino, multistream({ stream: iopts.stream, level: iopts.level })))
return fixLevel(pino(toPino, multistream({ stream: iopts.stream, level: iopts.level }, opts)))

@@ -33,0 +33,0 @@ function fixLevel (pino) {

@@ -15,3 +15,3 @@ 'use strict'

function multistream (streamsArray) {
function multistream (streamsArray, opts) {
var counter = 0

@@ -21,2 +21,4 @@

opts = opts || { dedupe: false }
const res = {

@@ -62,3 +64,5 @@ write,

}
stream.write(data)
if (!opts.dedupe) {
stream.write(data)
}
} else {

@@ -68,2 +72,6 @@ break

}
if (opts.dedupe && stream) {
stream.write(data)
}
}

@@ -70,0 +78,0 @@

{
"name": "pino-multi-stream",
"version": "5.0.0",
"version": "5.1.0",
"description": "A wrapper for the Pino logger that provides Bunyan's multipe destination stream API",

@@ -33,3 +33,3 @@ "main": "index.js",

"flush-write-stream": "^1.1.1",
"pino-pretty": "^4.0.0",
"pino-pretty": "^4.0.2",
"pre-commit": "^1.2.2",

@@ -36,0 +36,0 @@ "split2": "^3.1.1",

@@ -95,3 +95,3 @@ # pino-multi-stream ![CI](https://github.com/pinojs/pino-multi-stream/workflows/CI/badge.svg)

### pinoms.multistream(streams)
### pinoms.multistream(streams, opts)

@@ -121,2 +121,27 @@ Manually create a single `multistream` as used internally by the

`opts` multistream options object. Available options are:
+ `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 log = pino({
level: 'debug' // this MUST be set at the lowest level of the
// destinations
}, multistream(streams, { dedupe: true }))
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

@@ -123,0 +148,0 @@

@@ -327,2 +327,32 @@ 'use strict'

test('dedupe', function (t) {
var messageCount = 0
var stream1 = writeStream(function (data, enc, cb) {
messageCount += 1
cb()
})
var stream2 = writeStream(function (data, enc, cb) {
messageCount += 1
cb()
})
var streams = [
{
stream: stream1
},
{
stream: stream2,
level: 'fatal'
}
]
var log = pino({
level: 'trace'
}, multistream(streams, { dedupe: true }))
log.fatal('fatal stream')
t.is(messageCount, 1)
t.done()
})
test('no stream', function (t) {

@@ -329,0 +359,0 @@ var log = pino({

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc