Comparing version 6.2.1 to 6.3.0
@@ -61,6 +61,6 @@ 'use strict' | ||
var setOpts = { | ||
transmit: transmit, | ||
serialize: serialize, | ||
transmit, | ||
serialize, | ||
asObject: opts.browser.asObject, | ||
levels: levels | ||
levels | ||
} | ||
@@ -195,6 +195,6 @@ logger.levels = pino.levels | ||
transmit(this, { | ||
ts: ts, | ||
ts, | ||
methodLevel: level, | ||
methodValue: methodValue, | ||
transmitLevel: transmitLevel, | ||
methodValue, | ||
transmitLevel, | ||
transmitValue: pino.levels.values[opts.transmit.level || logger.level], | ||
@@ -201,0 +201,0 @@ send: opts.transmit.send, |
@@ -114,5 +114,5 @@ # API | ||
logger.info('hello') | ||
// {"level":30,"time":1573664685466,"pid":78742,"hostname":"x","line":1,"msg":"hello","v":1} | ||
// {"level":30,"time":1573664685466,"pid":78742,"hostname":"x","line":1,"msg":"hello"} | ||
logger.info('world') | ||
// {"level":30,"time":1573664685469,"pid":78742,"hostname":"x","line":2,"msg":"world","v":1} | ||
// {"level":30,"time":1573664685469,"pid":78742,"hostname":"x","line":2,"msg":"world"} | ||
``` | ||
@@ -289,3 +289,3 @@ | ||
If there's a chance that objects being logged have properties that conflict with those from pino itself (`level`, `timestamp`, `v`, `pid`, etc) | ||
If there's a chance that objects being logged have properties that conflict with those from pino itself (`level`, `timestamp`, `pid`, etc) | ||
and duplicate keys in your log records are undesirable, pino can be configured with a `nestedKey` option that causes any `object`s that are logged | ||
@@ -306,3 +306,3 @@ to be placed under a key whose name is the value of `nestedKey`. | ||
// logs the following: | ||
// {"level":30,"time":1578357790020,"pid":91736,"hostname":"x","payload":{"level":"hi","time":"never","foo":"bar"},"v":1} | ||
// {"level":30,"time":1578357790020,"pid":91736,"hostname":"x","payload":{"level":"hi","time":"never","foo":"bar"}} | ||
``` | ||
@@ -677,4 +677,4 @@ In this way, logged objects' properties don't conflict with pino's standard logging properties, | ||
used to flush the logs | ||
on an long interval, say ten seconds. Such a strategy can provide an | ||
optimium balance between extremely efficient logging at high demand periods | ||
on a long interval, say ten seconds. Such a strategy can provide an | ||
optimum balance between extremely efficient logging at high demand periods | ||
and safer logging at low demand periods. | ||
@@ -844,3 +844,3 @@ | ||
on every write. This is important to guarantee final log writes, | ||
both when using `pino.extreme` target. | ||
when using `pino.destination({ sync: false })` target. | ||
@@ -882,4 +882,4 @@ Since final log writes cannot be guaranteed with normal Node.js streams, | ||
* See [Exit logging help](/docs/help.md#exit-logging) | ||
* See [Extreme mode ⇗](/docs/extreme.md) | ||
* See [Log loss prevention ⇗](/docs/extreme.md#log-loss-prevention) | ||
* See [Asynchronous logging ⇗](/docs/asynchronous.md) | ||
* See [Log loss prevention ⇗](/docs/asynchronous.md#log-loss-prevention) | ||
@@ -886,0 +886,0 @@ <a id="pino-stdserializers"></a> |
@@ -33,7 +33,7 @@ # Asynchronous Logging | ||
So in summary, only use extreme mode when performing an extreme amount of | ||
logging and it is acceptable to potentially lose the most recent logs. | ||
So in summary, use asynchronous logging only when performing an extreme amount of | ||
logging, and it is acceptable to potentially lose the most recent logs. | ||
* Pino will register handlers for the following process events/signals so that | ||
Pino can flush the extreme mode buffer: | ||
Pino can flush the asynchronous logger buffer: | ||
@@ -107,9 +107,4 @@ + `beforeExit` | ||
An extreme destination is an instance of | ||
[`SonicBoom`](https://github.com/mcollina/sonic-boom) with `4096` | ||
buffering. | ||
* See [`pino.destination` api](/docs/api.md#pino-destination) | ||
* See [`pino.final` api](/docs/api.md#pino-final) | ||
* See [`destination` parameter](/docs/api.md#destination) |
@@ -72,2 +72,2 @@ # Pino Ecosystem | ||
+ [`cls-proxify`](https://github.com/keenondrums/cls-proxify): integration of pino and [CLS](https://github.com/jeff-lewis/cls-hooked). Useful for creating dynamically configured child loggers (e.g. with added trace ID) for each request. | ||
+ [`pino-tiny`](https://github.com/holmok/pino-tiny): a tiny (and exentsible?) little log formatter for pino. |
@@ -23,3 +23,3 @@ # Help | ||
Writing to a Node.js stream on exit is not necessarily guaranteed, and naively writing | ||
to an Extreme Mode logger on exit will definitely lead to lost logs. | ||
to an asynchronous logger on exit will definitely lead to lost logs. | ||
@@ -79,4 +79,4 @@ To write logs in an exit handler, create the handler with [`pino.final`](/docs/api.md#pino-final): | ||
In cases where a log rotation tool doesn't offer a copy-truncate capabilities, | ||
or where using them is deemed inappropriate `pino.destination` and `pino.extreme` | ||
destinations are able to reopen file paths after a file has been moved away. | ||
or where using them is deemed inappropriate, `pino.destination` | ||
is able to reopen file paths after a file has been moved away. | ||
@@ -92,3 +92,3 @@ One way to use this is to set up a `SIGUSR2` or `SIGHUP` signal handler that | ||
const dest = pino.destination('/log/file') // pino.extreme will also work | ||
const dest = pino.destination('/log/file') | ||
const logger = require('pino')(dest) | ||
@@ -217,3 +217,3 @@ process.on('SIGHUP', () => dest.reopen()) | ||
can capture calls to `debug` loggers and run them | ||
through `pino` instead. This results in a 10x (20x in extreme mode) | ||
through `pino` instead. This results in a 10x (20x in asynchronous mode) | ||
performance improvement - even though `pino-debug` is logging additional | ||
@@ -220,0 +220,0 @@ data and wrapping it in JSON. |
@@ -36,5 +36,4 @@ # Pretty Printing | ||
if (typeof inputData === 'string') { | ||
const parsedData = someJsonParser(inputData) | ||
logObject = (isPinoLog(parsedData)) ? parsedData : undefined | ||
} else if (isObject(inputData) && isPinoLog(inputData)) { | ||
logObject = someJsonParser(inputData) | ||
} else if (isObject(inputData)) { | ||
logObject = inputData | ||
@@ -49,6 +48,2 @@ } | ||
} | ||
function isPinoLog (log) { | ||
return log && (log.hasOwnProperty('v') && log.v === 1) | ||
} | ||
} | ||
@@ -94,3 +89,16 @@ ``` | ||
that can be passed via `prettyPrint`. | ||
The default prettifier write stream does not guarantee final log writes. | ||
Correspondingly, a warning is written to logs on first synchronous flushing. | ||
This warning may be suppressed by passing `suppressFlushSyncWarning : true` to | ||
`prettyPrint`: | ||
```js | ||
const pino = require('pino') | ||
const log = pino({ | ||
prettyPrint: { | ||
suppressFlushSyncWarning: true | ||
} | ||
}) | ||
``` | ||
[pp]: https://github.com/pinojs/pino-pretty |
@@ -55,3 +55,3 @@ 'use strict' | ||
get level () { return this[getLevelSym]() }, | ||
set level (lvl) { return this[setLevelSym](lvl) }, | ||
set level (lvl) { this[setLevelSym](lvl) }, | ||
get levelVal () { return this[levelValSym] }, | ||
@@ -58,0 +58,0 @@ set levelVal (n) { throw Error('levelVal is read-only') }, |
@@ -131,3 +131,3 @@ 'use strict' | ||
} | ||
// this case explicity falls through to the next one | ||
// this case explicitly falls through to the next one | ||
case 'boolean': | ||
@@ -181,3 +181,3 @@ if (stringifier) value = stringifier(value) | ||
prettifier = prettifier.bind(instance) | ||
return prettifierMetaWrapper(prettifier(opts), dest) | ||
return prettifierMetaWrapper(prettifier(opts), dest, opts) | ||
} | ||
@@ -187,3 +187,3 @@ try { | ||
prettyFactory.asMetaWrapper = prettifierMetaWrapper | ||
return prettifierMetaWrapper(prettyFactory(opts), dest) | ||
return prettifierMetaWrapper(prettyFactory(opts), dest, opts) | ||
} catch (e) { | ||
@@ -194,3 +194,4 @@ throw Error('Missing `pino-pretty` module: `pino-pretty` must be installed separately') | ||
function prettifierMetaWrapper (pretty, dest) { | ||
function prettifierMetaWrapper (pretty, dest, opts) { | ||
opts = Object.assign({ suppressFlushSyncWarning: false }, opts) | ||
var warned = false | ||
@@ -204,3 +205,3 @@ return { | ||
flushSync () { | ||
if (warned) { | ||
if (opts.suppressFlushSyncWarning || warned) { | ||
return | ||
@@ -331,3 +332,3 @@ } | ||
if ('extreme' in opts) { | ||
throw Error('The extreme option has been removed, use pino.extreme instead') | ||
throw Error('The extreme option has been removed, use pino.destination({ sync: false }) instead') | ||
} | ||
@@ -369,3 +370,3 @@ if ('onTerminated' in opts) { | ||
if (typeof stream.flushSync !== 'function') { | ||
throw Error('final requires a stream that has a flushSync method, such as pino.destination and pino.extreme') | ||
throw Error('final requires a stream that has a flushSync method, such as pino.destination') | ||
} | ||
@@ -372,0 +373,0 @@ |
{ | ||
"name": "pino", | ||
"version": "6.2.1", | ||
"version": "6.3.0", | ||
"description": "super fast, all natural json logger", | ||
@@ -5,0 +5,0 @@ "main": "pino.js", |
@@ -122,5 +122,5 @@ 'use strict' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
msg: 'a string', | ||
@@ -141,5 +141,5 @@ hello: 'world' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
msg: 'string', | ||
@@ -186,5 +186,5 @@ hello: 'world' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
err: { | ||
@@ -208,5 +208,5 @@ type: 'Error', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
msg: 'hello world', | ||
@@ -259,4 +259,4 @@ hello: 'world' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 60, | ||
@@ -280,4 +280,4 @@ name: 'hello', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -300,4 +300,4 @@ fooMessage: message | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -316,4 +316,4 @@ stuff: object | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -408,4 +408,4 @@ hello: 'world' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 60, | ||
@@ -426,4 +426,4 @@ name: 'hello', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 60, | ||
@@ -444,4 +444,4 @@ name: 'hello', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -459,4 +459,4 @@ msg: 'foo bar' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -486,4 +486,4 @@ msg: 'foo bar', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 60, | ||
@@ -505,4 +505,4 @@ msg: 'a message' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -520,4 +520,4 @@ msg: '1' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -538,4 +538,4 @@ msg: '1', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -557,4 +557,4 @@ test: 'test' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -576,4 +576,4 @@ msg: 'hello' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -595,4 +595,4 @@ msg: 'hello' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -615,4 +615,4 @@ msg: 'hello' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -619,0 +619,0 @@ time: 'none', |
@@ -476,3 +476,3 @@ 'use strict' | ||
}) | ||
instance[name]({ err: err }) | ||
instance[name]({ err }) | ||
}) | ||
@@ -516,3 +516,3 @@ | ||
}) | ||
const instance = require('../browser')({ level: level }) | ||
const instance = require('../browser')({ level }) | ||
instance[level]('test') | ||
@@ -519,0 +519,0 @@ }) |
@@ -25,5 +25,5 @@ 'use strict' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
type: 'Error', | ||
@@ -46,5 +46,5 @@ msg: err.message, | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
type: 'bar', | ||
@@ -67,5 +67,5 @@ msg: err.message, | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
type: 'Error', | ||
@@ -93,5 +93,5 @@ msg: err.message, | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
err: { | ||
@@ -118,5 +118,5 @@ type: 'Error', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
level: level, | ||
pid, | ||
hostname, | ||
level, | ||
type: 'Error', | ||
@@ -171,4 +171,4 @@ msg: err.message, | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 60, | ||
@@ -175,0 +175,0 @@ type: 'Error', |
@@ -21,4 +21,4 @@ 'use strict' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 60, | ||
@@ -86,4 +86,4 @@ name: 'hello', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 60, | ||
@@ -90,0 +90,0 @@ name: 'hello', |
@@ -5,3 +5,3 @@ global.process = { __proto__: process, pid: 123456 } | ||
var pino = require(require.resolve('./../../')) | ||
var extreme = pino(pino.destination({ sync: false })).child({ hello: 'world' }) | ||
pino.final(extreme, (_, logger) => logger.info('h'))() | ||
var asyncLogger = pino(pino.destination({ sync: false })).child({ hello: 'world' }) | ||
pino.final(asyncLogger, (_, logger) => logger.info('h'))() |
@@ -5,3 +5,3 @@ global.process = { __proto__: process, pid: 123456 } | ||
var pino = require(require.resolve('./../../')) | ||
var extreme = pino(pino.destination({ minLength: 4096, sync: false })) | ||
pino.final(extreme, (_, logger) => logger.info('h'))() | ||
var asyncLogger = pino(pino.destination({ minLength: 4096, sync: false })) | ||
pino.final(asyncLogger, (_, logger) => logger.info('h'))() |
@@ -19,4 +19,4 @@ 'use strict' | ||
same(chunk, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -58,4 +58,4 @@ msg: 'my request', | ||
same(chunk, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -75,3 +75,3 @@ msg: 'my request', | ||
originalReq = req | ||
instance.info({ req: req }, 'my request') | ||
instance.info({ req }, 'my request') | ||
res.end('hello') | ||
@@ -99,4 +99,4 @@ }) | ||
const expected = { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -120,3 +120,3 @@ msg: 'my request', | ||
delete req.connection | ||
instance.info({ req: req }, 'my request') | ||
instance.info({ req }, 'my request') | ||
res.end('hello') | ||
@@ -140,4 +140,4 @@ }) | ||
same(chunk, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -177,4 +177,4 @@ msg: 'my response', | ||
same(chunk, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -196,3 +196,3 @@ msg: 'my response', | ||
res.end('hello') | ||
instance.info({ res: res }, 'my response') | ||
instance.info({ res }, 'my response') | ||
}) | ||
@@ -220,4 +220,4 @@ | ||
same(chunk, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -237,3 +237,3 @@ msg: 'my request', | ||
originalReq = req | ||
const child = instance.child({ req: req }) | ||
const child = instance.child({ req }) | ||
child.info('my request') | ||
@@ -240,0 +240,0 @@ res.end('hello') |
@@ -24,4 +24,4 @@ 'use strict' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -49,4 +49,4 @@ hello: 'world', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -76,4 +76,4 @@ hello: 'world', | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -100,4 +100,4 @@ msg: 'a msg' | ||
same(result, { | ||
pid: pid, | ||
hostname: hostname, | ||
pid, | ||
hostname, | ||
level: 30, | ||
@@ -104,0 +104,0 @@ hello: 'world' |
@@ -290,2 +290,14 @@ 'use strict' | ||
test('suppress flush sync warning when corresponding option is specified', async ({ isNot, is }) => { | ||
var actual = '' | ||
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'suppress-flush-sync-warning.js')]) | ||
child.stdout.pipe(writer((s, enc, cb) => { | ||
actual += s | ||
cb() | ||
})) | ||
await once(child, 'close') | ||
is(strip(actual).match(/WARN\s+\(123456 on abcdefghijklmnopqr\): pino.final with prettyPrint does not support flushing/), null) | ||
}) | ||
test('works as expected with an object with the msg prop', async ({ isNot }) => { | ||
@@ -292,0 +304,0 @@ var actual = '' |
@@ -11,3 +11,3 @@ 'use strict' | ||
test('extreme mode', async ({ is, teardown }) => { | ||
test('asynchronous logging', async ({ is, teardown }) => { | ||
const now = Date.now | ||
@@ -35,3 +35,3 @@ const hostname = os.hostname | ||
} | ||
const extreme = pino(dest) | ||
const asyncLogger = pino(dest) | ||
@@ -41,3 +41,3 @@ var i = 44 | ||
normal.info('h') | ||
extreme.info('h') | ||
asyncLogger.info('h') | ||
} | ||
@@ -89,3 +89,3 @@ | ||
dest.write = function (s) { actual += s } | ||
const extreme = pino(dest).child({ hello: 'world' }) | ||
const asyncLogger = pino(dest).child({ hello: 'world' }) | ||
@@ -95,6 +95,6 @@ var i = 500 | ||
normal.info('h') | ||
extreme.info('h') | ||
asyncLogger.info('h') | ||
} | ||
extreme.flush() | ||
asyncLogger.flush() | ||
@@ -101,0 +101,0 @@ var expected2 = expected.split('\n')[0] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
301894
83
7098
29