Skip to content

Commit

Permalink
Removed multistream prettyPrint deprecation and clean up docs (#1123)
Browse files Browse the repository at this point in the history
* Removed multistream prettyPrint deprecation and clean up docs

* Update docs/api.md

Co-authored-by: James Sumners <james@sumners.email>

Co-authored-by: James Sumners <james@sumners.email>
  • Loading branch information
mcollina and jsumners committed Sep 13, 2021
1 parent a802d5e commit 8fb98ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
9 changes: 3 additions & 6 deletions docs/api.md
Expand Up @@ -453,9 +453,6 @@ set on the `destination` object after each log line is written:
* the last logger instance as `destination.lastLogger` (to support child
loggers)

For a full reference for using `Symbol.for('pino.metadata')`, see the [`pino-multi-stream` ⇗](https://github.com/pinojs/pino-multi-stream)
module.

The following is a succinct usage example:

```js
Expand All @@ -470,8 +467,6 @@ console.log(
) // Logged message "hi" at level 30 with object { a: 1 } at time 1531590545089
```
* See [`pino-multi-stream` ⇗](https://github.com/pinojs/pino-multi-stream)
<a id="logger"></a>
## Logger Instance
Expand Down Expand Up @@ -1056,8 +1051,10 @@ Create a stream composed by multiple destination streams:
```js
var fs = require('fs')
var pino = require('pino')
var pretty = require('pino-pretty')
var streams = [
{stream: fs.createWriteStream('/tmp/info.stream.out')},
{stream: pretty() },
{level: 'debug', stream: fs.createWriteStream('/tmp/debug.stream.out')},
{level: 'fatal', stream: fs.createWriteStream('/tmp/fatal.stream.out')}
]
Expand All @@ -1080,7 +1077,7 @@ In order for `multistream` to work, the log level __must__ be set to the lowest
+ `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`:
`dedupe` flag can be useful for example when using `pino.multistream` to redirect `error` logs to `process.stderr` and others to `process.stdout`:
```js
var pino = require('pino')
Expand Down
19 changes: 11 additions & 8 deletions test/multistream.test.js
Expand Up @@ -7,6 +7,8 @@ const os = require('os')
const test = require('tap').test
const pino = require('../')
const multistream = pino.multistream
const proxyquire = require('proxyquire')
const strip = require('strip-ansi')

test('sends to multiple streams using string levels', function (t) {
let messageCount = 0
Expand Down Expand Up @@ -213,23 +215,24 @@ test('supports custom levels', function (t) {
})

test('supports pretty print', function (t) {
t.plan(2)
const stream = writeStream(function (data, enc, cb) {
t.not(data.toString().match(/INFO.*: pretty print/), null)
t.end()
t.not(strip(data.toString()).match(/INFO.*: pretty print/), null)
cb()
})
const outStream = pino({
prettyPrint: {
levelFirst: true,
colorize: false

const pretty = proxyquire('pino-pretty', {
'sonic-boom': function () {
t.pass('sonic created')
return stream
}
}, stream)
})

const log = pino({
level: 'debug',
name: 'helloName'
}, multistream([
{ stream: outStream[pino.symbols.streamSym] }
{ stream: pretty() }
]))

log.info('pretty print')
Expand Down

0 comments on commit 8fb98ce

Please sign in to comment.