diff --git a/pino.js b/pino.js index e8feaca03..c2efc47ea 100644 --- a/pino.js +++ b/pino.js @@ -46,7 +46,7 @@ Object.defineProperty(nums, '100', { }) function pino (opts, stream) { - if (opts && opts._writableState) { + if (opts && (opts.writable || opts._writableState)) { stream = opts opts = null } diff --git a/test/basic.test.js b/test/basic.test.js index 8ef24c592..b6b75a21e 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -291,3 +291,27 @@ test('correctly escape msg strings', function (t) { instance.fatal('this contains "') }) + +test('correctly support node v4+ stderr', function (t) { + t.plan(1) + + // stderr inherits from Stream, rather than Writable + var dest = { + writable: true, + write: function (chunk) { + chunk = JSON.parse(chunk) + delete chunk.time + t.deepEqual(chunk, { + pid: pid, + hostname: hostname, + level: 60, + msg: 'a message', + v: 1 + }) + } + } + + var instance = pino(dest) + + instance.fatal('a message') +})