diff --git a/lib/multistream.js b/lib/multistream.js index 8b225c9a2..8f5e76ad2 100644 --- a/lib/multistream.js +++ b/lib/multistream.js @@ -13,9 +13,11 @@ function multistream (streamsArray, opts) { streamsArray = streamsArray || [] opts = opts || { dedupe: false } - let levels = defaultLevels + const levels = defaultLevels if (opts.levels && typeof opts.levels === 'object') { - levels = opts.levels + Object.keys(opts.levels).forEach(i => { + levels[i] = opts.levels[i] + }) } const res = { diff --git a/test/transport/core.test.js b/test/transport/core.test.js index 286d74486..948e46ed8 100644 --- a/test/transport/core.test.js +++ b/test/transport/core.test.js @@ -201,6 +201,30 @@ test('pino.transport with two files and custom levels', async ({ same, teardown }) }) +test('pino.transport without specifying default levels', async ({ same, teardown }) => { + const dest = file() + const transport = pino.transport({ + targets: [{ + level: 'foo', + target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'), + options: { destination: dest } + }], + levels: { foo: 25 } + }) + teardown(transport.end.bind(transport)) + const instance = pino(transport) + instance.info('hello') + await Promise.all([watchFileCreated(dest)]) + const result1 = JSON.parse(await readFile(dest)) + delete result1.time + same(result1, { + pid, + hostname, + level: 30, + msg: 'hello' + }) +}) + test('pino.transport with two files and dedupe', async ({ same, teardown }) => { const dest1 = file() const dest2 = file()