Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into disable-finalizationregistry-withnode-code…
…-cov Signed-off-by: Matteo Collina <hello@matteocollina.com>
- Loading branch information
Showing
61 changed files
with
3,171 additions
and
1,865 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,8 @@ | ||
{ | ||
"extends": [ | ||
"standard" | ||
], | ||
"rules": { | ||
"no-var": "off" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
coverage: true | ||
coverage-map: 'coverage-map.js' | ||
|
||
reporter: terse | ||
|
||
files: | ||
- 'lib/**/*.test.js' | ||
- 'test/**/*.test.js' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
'use strict' | ||
|
||
// We do not expect amazing numbers from `pino-pretty` as the whole purpose | ||
// of the module is a very slow operation. However, this benchmark should give | ||
// us some guidance on how features, or code changes, will affect the | ||
// performance of the module. | ||
|
||
const bench = require('fastbench') | ||
const { | ||
prettyFactory | ||
} = require('./index') | ||
|
||
const max = 10 | ||
const tstampMillis = 1693401358754 | ||
|
||
/* eslint-disable no-var */ | ||
const run = bench([ | ||
function basicLog (cb) { | ||
const pretty = prettyFactory({}) | ||
const input = `{"time":${tstampMillis},"pid":1,"hostname":"foo","msg":"benchmark","foo":"foo","bar":{"bar":"bar"}}\n` | ||
for (var i = 0; i < max; i += 1) { | ||
pretty(input) | ||
} | ||
setImmediate(cb) | ||
}, | ||
|
||
function objectLog (cb) { | ||
const pretty = prettyFactory({}) | ||
const input = { | ||
time: tstampMillis, | ||
pid: 1, | ||
hostname: 'foo', | ||
msg: 'benchmark', | ||
foo: 'foo', | ||
bar: { bar: 'bar' } | ||
} | ||
for (var i = 0; i < max; i += 1) { | ||
pretty(input) | ||
} | ||
setImmediate(cb) | ||
}, | ||
|
||
function coloredLog (cb) { | ||
const pretty = prettyFactory({ colorize: true }) | ||
const input = `{"time":${tstampMillis},"pid":1,"hostname":"foo","msg":"benchmark","foo":"foo","bar":{"bar":"bar"}}\n` | ||
for (var i = 0; i < max; i += 1) { | ||
pretty(input) | ||
} | ||
setImmediate(cb) | ||
}, | ||
|
||
function customPrettifiers (cb) { | ||
const pretty = prettyFactory({ | ||
customPrettifiers: { | ||
time (tstamp) { | ||
return tstamp | ||
}, | ||
pid () { | ||
return '' | ||
} | ||
} | ||
}) | ||
const input = `{"time":${tstampMillis},"pid":1,"hostname":"foo","msg":"benchmark","foo":"foo","bar":{"bar":"bar"}}\n` | ||
for (var i = 0; i < max; i += 1) { | ||
pretty(input) | ||
} | ||
setImmediate(cb) | ||
}, | ||
|
||
function logWithErrorObject (cb) { | ||
const pretty = prettyFactory({}) | ||
const err = Error('boom') | ||
const input = `{"time":${tstampMillis},"pid":1,"hostname":"foo","msg":"benchmark","foo":"foo","bar":{"bar":"bar"},"err":{"message":"${err.message}","stack":"${err.stack}"}}\n` | ||
for (var i = 0; i < max; i += 1) { | ||
pretty(input) | ||
} | ||
setImmediate(cb) | ||
}, | ||
|
||
function logRemappedMsgErrKeys (cb) { | ||
const pretty = prettyFactory({ | ||
messageKey: 'message', | ||
errorLikeObjectKeys: ['myError'] | ||
}) | ||
const err = Error('boom') | ||
const input = `{"time":${tstampMillis},"pid":1,"hostname":"foo","message":"benchmark","foo":"foo","bar":{"bar":"bar"},"myError":{"message":"${err.message}","stack":"${err.stack}"}}\n` | ||
for (var i = 0; i < max; i += 1) { | ||
pretty(input) | ||
} | ||
setImmediate(cb) | ||
}, | ||
|
||
function messageFormatString (cb) { | ||
const pretty = prettyFactory({ | ||
messageFormat: '{levelLabel}{if pid} {pid} - {end}{msg}' | ||
}) | ||
const input = `{"time":${tstampMillis},"pid":1,"hostname":"foo","msg":"benchmark","foo":"foo","bar":{"bar":"bar"}}\n` | ||
for (var i = 0; i < max; i += 1) { | ||
pretty(input) | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
module.exports = testFile => { | ||
// Ignore coverage on files that do not have a direct corollary. | ||
if (testFile.startsWith('test/')) return false | ||
|
||
// Indicate the matching name, sans '.test.js', should be checked for coverage. | ||
return testFile.replace(/\.test\.js$/, '.js') | ||
} |
Oops, something went wrong.