From 5a999f964edfaa654b8c734f1c9d1c46b44e965f Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Tue, 29 May 2018 02:44:49 +0200 Subject: [PATCH 01/12] fix: format opts typo --- pino.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pino.js b/pino.js index 697b15f..a2caa89 100644 --- a/pino.js +++ b/pino.js @@ -320,7 +320,7 @@ function pino (opts, stream) { instance.timestamp = iopts.timestamp instance.slowtime = iopts.slowtime instance.cache = iopts.cache - instance.formatiopts = iopts.formatiopts + instance.formatOpts = iopts.formatOpts instance.onTerminated = iopts.onTerminated instance.messageKey = iopts.messageKey instance.messageKeyString = iopts.messageKeyString From e926df7a2fca9cb684916a63caa8829267cb5211 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Sat, 2 Jun 2018 14:21:05 +0200 Subject: [PATCH 02/12] correct interpolation safety behaviour --- pino.js | 2 +- test/basic.test.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pino.js b/pino.js index a2caa89..d7ad5b7 100644 --- a/pino.js +++ b/pino.js @@ -297,7 +297,7 @@ function pino (opts, stream) { // internal options iopts.stringify = iopts.safe ? stringifySafe : JSON.stringify - iopts.formatOpts = {lowres: true} + iopts.formatOpts = {lowres: !iopts.safe} iopts.messageKeyString = `,"${iopts.messageKey}":` iopts.end = ',"v":' + LOG_VERSION + '}' + (iopts.crlf ? '\r\n' : '\n') iopts.cache = !iopts.extreme ? null : { diff --git a/test/basic.test.js b/test/basic.test.js index fed25f7..d5c37e2 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -506,3 +506,25 @@ test('when safe is true it should ONLY use `fast-safe-stringify`', function (t) }) t.end() }) + +test('when safe is true, fast-safe-stringify must be used when interpolating', function (t) { + var instance = pino({safe: true}, sink(function (chunk, enc, cb) { + const { msg } = chunk + t.is(msg, 'test {"a":{"b":{"c":"[Circular]"}}}') + t.end() + })) + var o = { a: { b: {} } } + o.a.b.c = o.a.b + instance.info('test', o) +}) + +test('when safe is false, interpolation output circulars at the root', function (t) { + var instance = pino({safe: false}, sink(function (chunk, enc, cb) { + const { msg } = chunk + t.is(msg, 'test "[Circular]"') + t.end() + })) + var o = { a: { b: {} } } + o.a.b.c = o.a.b + instance.info('test', o) +}) From 36d4d265e7d04bd871fc08f21d399b3066e83fb6 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Sat, 2 Jun 2018 14:29:15 +0200 Subject: [PATCH 03/12] 4.17.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 150aecb..8b77fcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pino", - "version": "4.17.2", + "version": "4.17.3", "description": "super fast, all natural json logger", "main": "pino.js", "browser": "./browser.js", From 9a2ae1eed23dca25cdb4f494b00a7ffc055115a8 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Sat, 2 Jun 2018 14:36:37 +0200 Subject: [PATCH 04/12] hot fix: node v4 syntax --- test/basic.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/basic.test.js b/test/basic.test.js index d5c37e2..d0aa17b 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -509,7 +509,7 @@ test('when safe is true it should ONLY use `fast-safe-stringify`', function (t) test('when safe is true, fast-safe-stringify must be used when interpolating', function (t) { var instance = pino({safe: true}, sink(function (chunk, enc, cb) { - const { msg } = chunk + var msg = chunk.msg t.is(msg, 'test {"a":{"b":{"c":"[Circular]"}}}') t.end() })) @@ -520,7 +520,7 @@ test('when safe is true, fast-safe-stringify must be used when interpolating', f test('when safe is false, interpolation output circulars at the root', function (t) { var instance = pino({safe: false}, sink(function (chunk, enc, cb) { - const { msg } = chunk + var msg = chunk.msg t.is(msg, 'test "[Circular]"') t.end() })) From f09d6613fa6d42780e4eb780872ef39a93e7b3a3 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Sat, 2 Jun 2018 14:39:42 +0200 Subject: [PATCH 05/12] 4.17.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b77fcb..2d5cd7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pino", - "version": "4.17.3", + "version": "4.17.4", "description": "super fast, all natural json logger", "main": "pino.js", "browser": "./browser.js", From 5a098091723f60fc21200f4bded1921260e41dc3 Mon Sep 17 00:00:00 2001 From: crobbins Date: Tue, 12 Jun 2018 14:52:34 -0400 Subject: [PATCH 06/12] [doc] Use winston@3 proper. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2d5cd7c..ad54e67 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "tap": "^11.1.5", "tape": "^4.9.0", "through2": "^2.0.3", - "winston": "^3.0.0-rc5" + "winston": "^3.0.0" }, "dependencies": { "chalk": "^2.4.1", From ed4428e022d66707850bbc467f1eeb1507a219c8 Mon Sep 17 00:00:00 2001 From: Osmond van Hemert Date: Thu, 19 Jul 2018 19:50:57 +0200 Subject: [PATCH 07/12] added reference to pino-papertrail transport (#455) * add pino-papertrail transport * headers fix --- docs/transports.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/transports.md b/docs/transports.md index 7cbfdec..a61c637 100644 --- a/docs/transports.md +++ b/docs/transports.md @@ -34,11 +34,11 @@ If you write a transport, let us know and we will add a link here! + [pino-couch](#pino-couch) + [pino-elasticsearch](#pino-elasticsearch) + [pino-mq](#pino-mq) ++ [pino-papertrail](#pino-papertrail) + [pino-redis](#pino-redis) + [pino-socket](#pino-socket) + [pino-syslog](#pino-syslog) - ### pino-couch @@ -113,6 +113,20 @@ pino-mq -g for full documentation of command line switches and pino-mq.json read [readme](https://github.com/itavy/pino-mq#readme) + +### pino-papertrail +pino-papertrail is a transport that will forward logs to the [papertrail](https://papertrailapp.com) log service through an UDPv4 socket. + +Given an application `foo` that logs via pino, and a papertrail destination that collects logs on port UDP `12345` on address `bar.papertrailapp.com`, you would use `pino-papertrail` +like so: + +``` +node yourapp.js | pino-papertrail --host bar.papertrailapp.com --port 12345 --appname foo +``` + + +for full documentation of command line switches read [readme](https://github.com/ovhemert/pino-papertrail#readme) + ### pino-redis From 3a1478979fa48ad163ac09e777fe4274f8b9c5ef Mon Sep 17 00:00:00 2001 From: George Haidar Date: Fri, 20 Jul 2018 16:30:16 +0100 Subject: [PATCH 08/12] fix: support logging errors that do not contain a stack (#457) Custom errors may not have their stack property set. Pino used to serialize undefined stack which created invalid JSON output --- pino.js | 3 ++- pretty.js | 4 +++- test/error.test.js | 15 +++++++++++++++ test/pretty.test.js | 18 ++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/pino.js b/pino.js index d7ad5b7..ff34c3b 100644 --- a/pino.js +++ b/pino.js @@ -146,7 +146,8 @@ function asJson (obj, msg, num, time) { if (hasObj) { var notHasOwnProperty = obj.hasOwnProperty === undefined if (objError) { - data += ',"type":"Error","stack":' + this.stringify(obj.stack) + data += ',"type":"Error"' + data += obj.stack ? ',"stack":' + this.stringify(obj.stack) : '' } // if global serializer is set, call it first if (this.serializers[Symbol.for('pino.*')]) { diff --git a/pretty.js b/pretty.js index 6d8c2d8..a2bdeeb 100755 --- a/pretty.js +++ b/pretty.js @@ -217,7 +217,9 @@ function pretty (opts) { line += eol if (value.type === 'Error') { - line += ' ' + withSpaces(value.stack, eol) + eol + line += value.stack + ? ' ' + withSpaces(value.stack, eol) + eol + : '' var propsForPrint if (errorProps && errorProps.length > 0) { diff --git a/test/error.test.js b/test/error.test.js index 005017c..dbdf1bc 100644 --- a/test/error.test.js +++ b/test/error.test.js @@ -128,3 +128,18 @@ test('an error with statusCode property is not confused for a http response', fu instance.level = name instance[name](err) }) + +test('stack is omitted if it is not set on err', t => { + t.plan(2) + var err = new Error('myerror') + delete err.stack + var instance = pino(sink(function (chunk, enc, cb) { + t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()') + delete chunk.time + t.equal(chunk.hasOwnProperty('stack'), false) + cb() + })) + + instance.level = name + instance[name](err) +}) diff --git a/test/pretty.test.js b/test/pretty.test.js index 2933161..dc34ee2 100644 --- a/test/pretty.test.js +++ b/test/pretty.test.js @@ -105,6 +105,24 @@ test('pino transform prettifies Error', function (t) { instance.info(err) }) +test('pino transform prettifies Error without stack', function (t) { + var prettier = pretty() + var err = new Error('hello world') + delete err.stack + var expected = [err.message] + + t.plan(expected.length) + + prettier.pipe(split(function (line) { + t.ok(line.indexOf(expected.shift()) >= 0, 'line matches') + return line + })) + + var instance = pino(prettier) + + instance.info(err) +}) + function getIndentLevel (str) { return (/^\s*/.exec(str) || [''])[0].length } From bf7db1035393b939f02223bbf49ec9efd5056dd9 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Fri, 20 Jul 2018 17:36:37 +0200 Subject: [PATCH 09/12] Updated dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ad54e67..f066188 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ }, "homepage": "http://getpino.io", "devDependencies": { - "airtap": "0.0.7", + "airtap": "0.1.0", "benchmark": "^2.1.4", "bole": "^3.0.2", "bunyan": "^1.8.12", @@ -70,7 +70,7 @@ "snazzy": "^7.1.1", "standard": "^11.0.1", "steed": "^1.1.3", - "tap": "^11.1.5", + "tap": "^12.0.0", "tape": "^4.9.0", "through2": "^2.0.3", "winston": "^3.0.0" From 2f14f6d86f0faeee97de1c54435d14b4066d7181 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Sat, 21 Jul 2018 00:18:36 +0200 Subject: [PATCH 10/12] Bumped v4.17.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f066188..21bba6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pino", - "version": "4.17.4", + "version": "4.17.5", "description": "super fast, all natural json logger", "main": "pino.js", "browser": "./browser.js", From 576c970e2f71554a1f748b9208ff7a3f0596e822 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Sun, 29 Jul 2018 09:48:16 -0700 Subject: [PATCH 11/12] Do not cast to string Error#stack. (#464) --- pino.js | 4 +++- test/error.test.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pino.js b/pino.js index ff34c3b..43b68b6 100644 --- a/pino.js +++ b/pino.js @@ -147,7 +147,9 @@ function asJson (obj, msg, num, time) { var notHasOwnProperty = obj.hasOwnProperty === undefined if (objError) { data += ',"type":"Error"' - data += obj.stack ? ',"stack":' + this.stringify(obj.stack) : '' + if (obj.stack !== undefined) { + data += ',"stack":' + this.stringify(obj.stack) + } } // if global serializer is set, call it first if (this.serializers[Symbol.for('pino.*')]) { diff --git a/test/error.test.js b/test/error.test.js index dbdf1bc..5bdb73d 100644 --- a/test/error.test.js +++ b/test/error.test.js @@ -143,3 +143,19 @@ test('stack is omitted if it is not set on err', t => { instance.level = name instance[name](err) }) + +test('stack is rendered as any other property if it\'s not a string', t => { + t.plan(3) + var err = new Error('myerror') + err.stack = null + var instance = pino(sink(function (chunk, enc, cb) { + t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()') + delete chunk.time + t.equal(chunk.hasOwnProperty('stack'), true) + t.equal(chunk.stack, null) + cb() + })) + + instance.level = name + instance[name](err) +}) From 44ba3311496e23c6964452e59005090121a55d52 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Sun, 29 Jul 2018 09:51:23 -0700 Subject: [PATCH 12/12] Bumped v4.17.6 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 21bba6d..c8c1cd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pino", - "version": "4.17.5", + "version": "4.17.6", "description": "super fast, all natural json logger", "main": "pino.js", "browser": "./browser.js", @@ -70,7 +70,7 @@ "snazzy": "^7.1.1", "standard": "^11.0.1", "steed": "^1.1.3", - "tap": "^12.0.0", + "tap": "^12.0.1", "tape": "^4.9.0", "through2": "^2.0.3", "winston": "^3.0.0"