UNPKG

pino

Version:

super fast, all natural json logger

40 lines (36 loc) 1.07 kB
'use strict' const os = require('os') const { join } = require('path') const { readFile } = require('fs').promises const { watchFileCreated } = require('../helper') const { test } = require('tap') const pino = require('../../') const { pid } = process const hostname = os.hostname() test('pino.transport with a pipeline', async ({ same, teardown }) => { const destination = join( os.tmpdir(), '_' + Math.random().toString(36).substr(2, 9) ) const transport = pino.transport({ pipeline: [{ target: join(__dirname, '..', 'fixtures', 'transport-transform.js') }, { target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'), options: { destination } }] }) teardown(transport.end.bind(transport)) const instance = pino(transport) instance.info('hello') await watchFileCreated(destination) const result = JSON.parse(await readFile(destination)) delete result.time same(result, { pid, hostname, level: 30, msg: 'hello', service: 'pino' // this property was added by the transform }) })