forked from pinojs/pino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add formatters for core log components (pinojs#775)
* WIP: added bindings and levels serializers * Addressed comments * Fixed test * Moved from custom srializers to formatters * Use stricter check in genLsCache * Updated test * Addressed comments * Added log formatter and removed pino.* serializer * Updated test * Use factory for formatters object * Added deprecations messages - deprecated useLevelLabels - deprecated changeLevelName - deprecated pino.* serializer * Updated test * Addressed comments * Fix test * Improve code coverage * Fixed levelKey handling * Updated test * Addressed comments * Updated test * Added formatters benchmarks * Rename test * 100% code coverage * Added formatters to benchmark runner * Updated documentation * Update docs/api.md Co-Authored-By: James Sumners <[email protected]> * Update docs/api.md Co-Authored-By: James Sumners <[email protected]> * Update docs/api.md Co-Authored-By: James Sumners <[email protected]> * Update docs/api.md Co-Authored-By: James Sumners <[email protected]> * Update docs/api.md Co-Authored-By: James Sumners <[email protected]> * Update docs/api.md Co-Authored-By: James Sumners <[email protected]> * Addressed comments Co-authored-by: James Sumners <[email protected]> Co-authored-by: Matteo Collina <[email protected]>
- Loading branch information
1 parent
5c85000
commit f3ab176
Showing
15 changed files
with
716 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict' | ||
|
||
const formatters = { | ||
level (label, number) { | ||
return { | ||
log: { | ||
level: label | ||
} | ||
} | ||
}, | ||
bindings (bindings) { | ||
return { | ||
process: { | ||
pid: bindings.pid | ||
}, | ||
host: { | ||
name: bindings.hostname | ||
} | ||
} | ||
}, | ||
log (obj) { | ||
return { foo: 'bar', ...obj } | ||
} | ||
} | ||
|
||
const bench = require('fastbench') | ||
const pino = require('../') | ||
delete require.cache[require.resolve('../')] | ||
const pinoNoFormatters = require('../')(pino.destination('/dev/null')) | ||
delete require.cache[require.resolve('../')] | ||
const pinoFormatters = require('../')({ formatters }, pino.destination('/dev/null')) | ||
|
||
const max = 10 | ||
|
||
const run = bench([ | ||
function benchPinoNoFormatters (cb) { | ||
for (var i = 0; i < max; i++) { | ||
pinoNoFormatters.info({ hello: 'world' }) | ||
} | ||
setImmediate(cb) | ||
}, | ||
function benchPinoFormatters (cb) { | ||
for (var i = 0; i < max; i++) { | ||
pinoFormatters.info({ hello: 'world' }) | ||
} | ||
setImmediate(cb) | ||
} | ||
], 10000) | ||
|
||
run(run) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.