-
Notifications
You must be signed in to change notification settings - Fork 854
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #566 from pinojs/make-destination-sync
Make pino.destination sync
- Loading branch information
Showing
10 changed files
with
117 additions
and
55 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
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
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
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
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,53 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const { join } = require('path') | ||
const execa = require('execa') | ||
const writer = require('flush-write-stream') | ||
const { once } = require('./helper') | ||
|
||
// https://github.com/pinojs/pino/issues/542 | ||
test('pino.destination log everything when calling process.exit(0)', async ({ isNot }) => { | ||
var actual = '' | ||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'destination-exit.js')]) | ||
|
||
child.stdout.pipe(writer((s, enc, cb) => { | ||
actual += s | ||
cb() | ||
})) | ||
|
||
await once(child, 'close') | ||
|
||
isNot(actual.match(/hello/), null) | ||
isNot(actual.match(/world/), null) | ||
}) | ||
|
||
test('pino.extreme does not log everything when calling process.exit(0)', async ({ is }) => { | ||
var actual = '' | ||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'extreme-exit.js')]) | ||
|
||
child.stdout.pipe(writer((s, enc, cb) => { | ||
actual += s | ||
cb() | ||
})) | ||
|
||
await once(child, 'close') | ||
|
||
is(actual.match(/hello/), null) | ||
is(actual.match(/world/), null) | ||
}) | ||
|
||
test('pino.extreme logs everything when calling flushSync', async ({ isNot }) => { | ||
var actual = '' | ||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'extreme-flush-exit.js')]) | ||
|
||
child.stdout.pipe(writer((s, enc, cb) => { | ||
actual += s | ||
cb() | ||
})) | ||
|
||
await once(child, 'close') | ||
|
||
isNot(actual.match(/hello/), null) | ||
isNot(actual.match(/world/), null) | ||
}) |
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
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,8 @@ | ||
global.process = { __proto__: process, pid: 123456 } | ||
Date.now = function () { return 1459875739796 } | ||
require('os').hostname = function () { return 'abcdefghijklmnopqr' } | ||
var pino = require(require.resolve('./../../')) | ||
var logger = pino({}, pino.destination(1)) | ||
logger.info('hello') | ||
logger.info('world') | ||
process.exit(0) |
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,9 @@ | ||
global.process = { __proto__: process, pid: 123456 } | ||
Date.now = function () { return 1459875739796 } | ||
require('os').hostname = function () { return 'abcdefghijklmnopqr' } | ||
var pino = require(require.resolve('./../../')) | ||
var dest = pino.extreme(1) | ||
var logger = pino({}, dest) | ||
logger.info('hello') | ||
logger.info('world') | ||
process.exit(0) |
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,10 @@ | ||
global.process = { __proto__: process, pid: 123456 } | ||
Date.now = function () { return 1459875739796 } | ||
require('os').hostname = function () { return 'abcdefghijklmnopqr' } | ||
var pino = require(require.resolve('./../../')) | ||
var dest = pino.extreme(1) | ||
var logger = pino({}, dest) | ||
logger.info('hello') | ||
logger.info('world') | ||
dest.flushSync() | ||
process.exit(0) |
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