-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove in-between Transform for file (#1140)
- Loading branch information
Showing
4 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
coverage: true | ||
timeout: 480 | ||
check-coverage: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,10 @@ | ||
'use strict' | ||
|
||
const { Transform, pipeline } = require('stream') | ||
const pino = require('./pino') | ||
const { once } = require('events') | ||
|
||
module.exports = async function (opts = {}) { | ||
const stream = new Transform({ | ||
objectMode: true, | ||
autoDestroy: true, | ||
transform (chunk, enc, cb) { | ||
cb(null, chunk.toString()) | ||
} | ||
}) | ||
|
||
const destination = pino.destination({ dest: opts.destination || 1, sync: false }) | ||
await once(destination, 'ready') | ||
pipeline(stream, destination, () => {}) | ||
return stream | ||
return destination | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
|
||
const pino = require('../..') | ||
const transport = pino.transport({ | ||
targets: [{ | ||
level: 'info', | ||
target: 'pino/file', | ||
options: { | ||
destination: process.argv[2] | ||
} | ||
}] | ||
}) | ||
const logger = pino(transport) | ||
|
||
const toWrite = 1000000 | ||
transport.on('ready', run) | ||
|
||
let total = 0 | ||
|
||
function run () { | ||
if (total++ === 8) { | ||
return | ||
} | ||
|
||
for (let i = 0; i < toWrite; i++) { | ||
logger.info(`hello ${i}`) | ||
} | ||
transport.once('drain', run) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters