UNPKG

pino

Version:

super fast, all natural json logger

35 lines (31 loc) 857 B
'use strict' const os = require('os') const pino = require('../..') const { join } = require('path') const { test } = require('tap') const { readFile } = require('fs').promises const { watchFileCreated } = require('../helper') const { pid } = process const hostname = os.hostname() test('thread-stream async flush', async ({ same }) => { const destination = join( os.tmpdir(), '_' + Math.random().toString(36).substr(2, 9) ) const transport = pino.transport({ target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'), options: { destination } }) const instance = pino(transport) instance.info('hello') instance.flush() await watchFileCreated(destination) const result = JSON.parse(await readFile(destination)) delete result.time same(result, { pid, hostname, level: 30, msg: 'hello' }) })