lucide-node 0.0.1-security → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lucide-node might be problematic. Click here for more details.
- package/.eslintignore +2 -0
- package/.eslintrc +8 -0
- package/.github/dependabot.yml +13 -0
- package/.github/workflows/bench.yml +61 -0
- package/.github/workflows/ci.yml +88 -0
- package/.github/workflows/lock-threads.yml +30 -0
- package/.github/workflows/target-main.yml +23 -0
- package/.nojekyll +0 -0
- package/.prettierignore +1 -0
- package/.taprc.yaml +8 -0
- package/CNAME +1 -0
- package/CONTRIBUTING.md +30 -0
- package/LICENSE +21 -0
- package/README.md +159 -3
- package/SECURITY.md +68 -0
- package/benchmarks/basic.bench.js +95 -0
- package/benchmarks/child-child.bench.js +52 -0
- package/benchmarks/child-creation.bench.js +73 -0
- package/benchmarks/child.bench.js +62 -0
- package/benchmarks/deep-object.bench.js +88 -0
- package/benchmarks/formatters.bench.js +50 -0
- package/benchmarks/internal/custom-levels.js +67 -0
- package/benchmarks/internal/just-pino-heavy.bench.js +76 -0
- package/benchmarks/internal/just-pino.bench.js +182 -0
- package/benchmarks/internal/parent-vs-child.bench.js +75 -0
- package/benchmarks/internal/redact.bench.js +86 -0
- package/benchmarks/long-string.bench.js +81 -0
- package/benchmarks/multi-arg.bench.js +193 -0
- package/benchmarks/multistream.js +98 -0
- package/benchmarks/object.bench.js +82 -0
- package/benchmarks/utils/generate-benchmark-doc.js +36 -0
- package/benchmarks/utils/runbench.js +138 -0
- package/benchmarks/utils/wrap-log-level.js +55 -0
- package/bin.js +6 -0
- package/browser.js +484 -0
- package/build/sync-version.js +10 -0
- package/docs/api.md +1487 -0
- package/docs/asynchronous.md +40 -0
- package/docs/benchmarks.md +55 -0
- package/docs/browser.md +227 -0
- package/docs/bundling.md +40 -0
- package/docs/child-loggers.md +95 -0
- package/docs/ecosystem.md +84 -0
- package/docs/help.md +345 -0
- package/docs/lts.md +64 -0
- package/docs/pretty.md +35 -0
- package/docs/redaction.md +135 -0
- package/docs/transports.md +1238 -0
- package/docs/web.md +269 -0
- package/docsify/sidebar.md +26 -0
- package/examples/basic.js +43 -0
- package/examples/transport.js +68 -0
- package/favicon-16x16.png +0 -0
- package/favicon-32x32.png +0 -0
- package/favicon.ico +0 -0
- package/file.js +12 -0
- package/inc-version.sh +42 -0
- package/index.html +55 -0
- package/lib/caller.js +30 -0
- package/lib/constants.js +28 -0
- package/lib/deprecations.js +8 -0
- package/lib/levels.js +241 -0
- package/lib/meta.js +3 -0
- package/lib/multistream.js +188 -0
- package/lib/proto.js +234 -0
- package/lib/redaction.js +118 -0
- package/lib/symbols.js +74 -0
- package/lib/time.js +11 -0
- package/lib/tools.js +394 -0
- package/lib/transport-stream.js +56 -0
- package/lib/transport.js +167 -0
- package/lib/worker.js +194 -0
- package/lib/writer.js +42 -0
- package/package.json +117 -3
- package/pino-banner.png +0 -0
- package/pino-logo-hire.png +0 -0
- package/pino-tree.png +0 -0
- package/pino.d.ts +889 -0
- package/pino.js +236 -0
- package/pretty-demo.png +0 -0
- package/test/basic.test.js +874 -0
- package/test/broken-pipe.test.js +57 -0
- package/test/browser-child.test.js +132 -0
- package/test/browser-disabled.test.js +87 -0
- package/test/browser-early-console-freeze.test.js +12 -0
- package/test/browser-levels.test.js +241 -0
- package/test/browser-serializers.test.js +352 -0
- package/test/browser-timestamp.test.js +88 -0
- package/test/browser-transmit.test.js +417 -0
- package/test/browser.test.js +659 -0
- package/test/complex-objects.test.js +34 -0
- package/test/crlf.test.js +32 -0
- package/test/custom-levels.test.js +253 -0
- package/test/error.test.js +398 -0
- package/test/errorKey.test.js +34 -0
- package/test/escaping.test.js +91 -0
- package/test/esm/esm.mjs +12 -0
- package/test/esm/index.test.js +34 -0
- package/test/esm/named-exports.mjs +27 -0
- package/test/exit.test.js +77 -0
- package/test/fixtures/broken-pipe/basic.js +9 -0
- package/test/fixtures/broken-pipe/destination.js +10 -0
- package/test/fixtures/broken-pipe/syncfalse.js +12 -0
- package/test/fixtures/console-transport.js +13 -0
- package/test/fixtures/default-exit.js +8 -0
- package/test/fixtures/destination-exit.js +8 -0
- package/test/fixtures/eval/index.js +13 -0
- package/test/fixtures/eval/node_modules/14-files.js +3 -0
- package/test/fixtures/eval/node_modules/2-files.js +3 -0
- package/test/fixtures/eval/node_modules/file1.js +5 -0
- package/test/fixtures/eval/node_modules/file10.js +5 -0
- package/test/fixtures/eval/node_modules/file11.js +5 -0
- package/test/fixtures/eval/node_modules/file12.js +5 -0
- package/test/fixtures/eval/node_modules/file13.js +5 -0
- package/test/fixtures/eval/node_modules/file14.js +11 -0
- package/test/fixtures/eval/node_modules/file2.js +5 -0
- package/test/fixtures/eval/node_modules/file3.js +5 -0
- package/test/fixtures/eval/node_modules/file4.js +5 -0
- package/test/fixtures/eval/node_modules/file5.js +5 -0
- package/test/fixtures/eval/node_modules/file6.js +5 -0
- package/test/fixtures/eval/node_modules/file7.js +5 -0
- package/test/fixtures/eval/node_modules/file8.js +5 -0
- package/test/fixtures/eval/node_modules/file9.js +5 -0
- package/test/fixtures/noop-transport.js +10 -0
- package/test/fixtures/pretty/null-prototype.js +8 -0
- package/test/fixtures/stdout-hack-protection.js +11 -0
- package/test/fixtures/syncfalse-child.js +6 -0
- package/test/fixtures/syncfalse-exit.js +9 -0
- package/test/fixtures/syncfalse-flush-exit.js +10 -0
- package/test/fixtures/syncfalse.js +6 -0
- package/test/fixtures/syntax-error-esm.mjs +2 -0
- package/test/fixtures/to-file-transport-with-transform.js +20 -0
- package/test/fixtures/to-file-transport.js +13 -0
- package/test/fixtures/to-file-transport.mjs +8 -0
- package/test/fixtures/transport/index.js +12 -0
- package/test/fixtures/transport/package.json +5 -0
- package/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
- package/test/fixtures/transport-exit-immediately.js +11 -0
- package/test/fixtures/transport-exit-on-ready.js +12 -0
- package/test/fixtures/transport-main.js +9 -0
- package/test/fixtures/transport-many-lines.js +29 -0
- package/test/fixtures/transport-string-stdout.js +9 -0
- package/test/fixtures/transport-transform.js +21 -0
- package/test/fixtures/transport-uses-pino-config.js +33 -0
- package/test/fixtures/transport-with-on-exit.js +12 -0
- package/test/fixtures/transport-worker-data.js +19 -0
- package/test/fixtures/transport-worker.js +15 -0
- package/test/fixtures/transport-wrong-export-type.js +3 -0
- package/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
- package/test/fixtures/ts/to-file-transport.ts +11 -0
- package/test/fixtures/ts/transpile.cjs +36 -0
- package/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
- package/test/fixtures/ts/transport-exit-immediately.ts +10 -0
- package/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
- package/test/fixtures/ts/transport-main.ts +8 -0
- package/test/fixtures/ts/transport-string-stdout.ts +8 -0
- package/test/fixtures/ts/transport-worker.ts +14 -0
- package/test/formatters.test.js +355 -0
- package/test/helper.d.ts +4 -0
- package/test/helper.js +128 -0
- package/test/hooks.test.js +118 -0
- package/test/http.test.js +242 -0
- package/test/internals/version.test.js +15 -0
- package/test/is-level-enabled.test.js +185 -0
- package/test/jest/basic.spec.js +10 -0
- package/test/levels.test.js +772 -0
- package/test/metadata.test.js +106 -0
- package/test/mixin-merge-strategy.test.js +55 -0
- package/test/mixin.test.js +218 -0
- package/test/multistream.test.js +673 -0
- package/test/pkg/index.js +46 -0
- package/test/pkg/pkg.config.json +17 -0
- package/test/pkg/pkg.test.js +56 -0
- package/test/redact.test.js +847 -0
- package/test/serializers.test.js +253 -0
- package/test/stdout-protection.test.js +39 -0
- package/test/syncfalse.test.js +188 -0
- package/test/timestamp.test.js +121 -0
- package/test/transport/big.test.js +43 -0
- package/test/transport/bundlers-support.test.js +97 -0
- package/test/transport/caller.test.js +23 -0
- package/test/transport/core.test.js +644 -0
- package/test/transport/core.test.ts +236 -0
- package/test/transport/core.transpiled.test.ts +112 -0
- package/test/transport/module-link.test.js +239 -0
- package/test/transport/pipeline.test.js +135 -0
- package/test/transport/repl.test.js +14 -0
- package/test/transport/syncTrue.test.js +55 -0
- package/test/transport/syncfalse.test.js +68 -0
- package/test/transport/targets.test.js +44 -0
- package/test/transport/uses-pino-config.test.js +167 -0
- package/test/transport-stream.test.js +26 -0
- package/test/types/pino-import.test-d.ts +29 -0
- package/test/types/pino-multistream.test-d.ts +28 -0
- package/test/types/pino-top-export.test-d.ts +35 -0
- package/test/types/pino-transport.test-d.ts +145 -0
- package/test/types/pino-type-only.test-d.ts +64 -0
- package/test/types/pino.test-d.ts +468 -0
- package/test/types/pino.ts +78 -0
- package/tsconfig.json +14 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
const t = require('tap')
|
4
|
+
const { join } = require('node:path')
|
5
|
+
const { fork } = require('node:child_process')
|
6
|
+
const { once } = require('./helper')
|
7
|
+
const pino = require('..')
|
8
|
+
|
9
|
+
if (process.platform === 'win32') {
|
10
|
+
t.skip('skipping on windows')
|
11
|
+
process.exit(0)
|
12
|
+
}
|
13
|
+
|
14
|
+
if (process.env.CITGM) {
|
15
|
+
// This looks like a some form of limitations of the CITGM test runner
|
16
|
+
// or the HW/SW we run it on. This file can hang on Node.js v18.x.
|
17
|
+
// The failure does not reproduce locally or on our CI.
|
18
|
+
// Skipping it is the only way to keep pino in CITGM.
|
19
|
+
// https://github.com/nodejs/citgm/pull/1002#issuecomment-1751942988
|
20
|
+
t.skip('Skipping on Node.js core CITGM because it hangs on v18.x')
|
21
|
+
process.exit(0)
|
22
|
+
}
|
23
|
+
|
24
|
+
function test (file) {
|
25
|
+
file = join('fixtures', 'broken-pipe', file)
|
26
|
+
t.test(file, { parallel: true }, async ({ equal }) => {
|
27
|
+
const child = fork(join(__dirname, file), { silent: true })
|
28
|
+
child.stdout.destroy()
|
29
|
+
|
30
|
+
child.stderr.pipe(process.stdout)
|
31
|
+
|
32
|
+
const res = await once(child, 'close')
|
33
|
+
equal(res, 0) // process exits successfully
|
34
|
+
})
|
35
|
+
}
|
36
|
+
|
37
|
+
t.jobs = 42
|
38
|
+
|
39
|
+
test('basic.js')
|
40
|
+
test('destination.js')
|
41
|
+
test('syncfalse.js')
|
42
|
+
|
43
|
+
t.test('let error pass through', ({ equal, plan }) => {
|
44
|
+
plan(3)
|
45
|
+
const stream = pino.destination({ sync: true })
|
46
|
+
|
47
|
+
// side effect of the pino constructor is that it will set an
|
48
|
+
// event handler for error
|
49
|
+
pino(stream)
|
50
|
+
|
51
|
+
process.nextTick(() => stream.emit('error', new Error('kaboom')))
|
52
|
+
process.nextTick(() => stream.emit('error', new Error('kaboom')))
|
53
|
+
|
54
|
+
stream.on('error', (err) => {
|
55
|
+
equal(err.message, 'kaboom')
|
56
|
+
})
|
57
|
+
})
|
@@ -0,0 +1,132 @@
|
|
1
|
+
'use strict'
|
2
|
+
const test = require('tape')
|
3
|
+
const pino = require('../browser')
|
4
|
+
|
5
|
+
test('child has parent level', ({ end, same, is }) => {
|
6
|
+
const instance = pino({
|
7
|
+
level: 'error',
|
8
|
+
browser: {}
|
9
|
+
})
|
10
|
+
|
11
|
+
const child = instance.child({})
|
12
|
+
|
13
|
+
same(child.level, instance.level)
|
14
|
+
end()
|
15
|
+
})
|
16
|
+
|
17
|
+
test('child can set level at creation time', ({ end, same, is }) => {
|
18
|
+
const instance = pino({
|
19
|
+
level: 'error',
|
20
|
+
browser: {}
|
21
|
+
})
|
22
|
+
|
23
|
+
const child = instance.child({}, { level: 'info' }) // first bindings, then options
|
24
|
+
|
25
|
+
same(child.level, 'info')
|
26
|
+
end()
|
27
|
+
})
|
28
|
+
|
29
|
+
test('changing child level does not affect parent', ({ end, same, is }) => {
|
30
|
+
const instance = pino({
|
31
|
+
level: 'error',
|
32
|
+
browser: {}
|
33
|
+
})
|
34
|
+
|
35
|
+
const child = instance.child({})
|
36
|
+
child.level = 'info'
|
37
|
+
|
38
|
+
same(instance.level, 'error')
|
39
|
+
end()
|
40
|
+
})
|
41
|
+
|
42
|
+
test('child should log, if its own level allows it', ({ end, same, is }) => {
|
43
|
+
const expected = [
|
44
|
+
{
|
45
|
+
level: 30,
|
46
|
+
msg: 'this is info'
|
47
|
+
},
|
48
|
+
{
|
49
|
+
level: 40,
|
50
|
+
msg: 'this is warn'
|
51
|
+
},
|
52
|
+
{
|
53
|
+
level: 50,
|
54
|
+
msg: 'this is an error'
|
55
|
+
}
|
56
|
+
]
|
57
|
+
const instance = pino({
|
58
|
+
level: 'error',
|
59
|
+
browser: {
|
60
|
+
write (actual) {
|
61
|
+
checkLogObjects(is, same, actual, expected.shift())
|
62
|
+
}
|
63
|
+
}
|
64
|
+
})
|
65
|
+
|
66
|
+
const child = instance.child({})
|
67
|
+
child.level = 'info'
|
68
|
+
|
69
|
+
child.debug('this is debug')
|
70
|
+
child.info('this is info')
|
71
|
+
child.warn('this is warn')
|
72
|
+
child.error('this is an error')
|
73
|
+
|
74
|
+
same(expected.length, 0, 'not all messages were read')
|
75
|
+
end()
|
76
|
+
})
|
77
|
+
|
78
|
+
test('changing child log level should not affect parent log behavior', ({ end, same, is }) => {
|
79
|
+
const expected = [
|
80
|
+
{
|
81
|
+
level: 50,
|
82
|
+
msg: 'this is an error'
|
83
|
+
},
|
84
|
+
{
|
85
|
+
level: 60,
|
86
|
+
msg: 'this is fatal'
|
87
|
+
}
|
88
|
+
]
|
89
|
+
const instance = pino({
|
90
|
+
level: 'error',
|
91
|
+
browser: {
|
92
|
+
write (actual) {
|
93
|
+
checkLogObjects(is, same, actual, expected.shift())
|
94
|
+
}
|
95
|
+
}
|
96
|
+
})
|
97
|
+
|
98
|
+
const child = instance.child({})
|
99
|
+
child.level = 'info'
|
100
|
+
|
101
|
+
instance.warn('this is warn')
|
102
|
+
instance.error('this is an error')
|
103
|
+
instance.fatal('this is fatal')
|
104
|
+
|
105
|
+
same(expected.length, 0, 'not all messages were read')
|
106
|
+
end()
|
107
|
+
})
|
108
|
+
|
109
|
+
test('onChild callback should be called when new child is created', ({ end, pass, plan }) => {
|
110
|
+
plan(1)
|
111
|
+
const instance = pino({
|
112
|
+
level: 'error',
|
113
|
+
browser: {},
|
114
|
+
onChild: (_child) => {
|
115
|
+
pass('onChild callback was called')
|
116
|
+
end()
|
117
|
+
}
|
118
|
+
})
|
119
|
+
|
120
|
+
instance.child({})
|
121
|
+
})
|
122
|
+
|
123
|
+
function checkLogObjects (is, same, actual, expected) {
|
124
|
+
is(actual.time <= Date.now(), true, 'time is greater than Date.now()')
|
125
|
+
|
126
|
+
const actualCopy = Object.assign({}, actual)
|
127
|
+
const expectedCopy = Object.assign({}, expected)
|
128
|
+
delete actualCopy.time
|
129
|
+
delete expectedCopy.time
|
130
|
+
|
131
|
+
same(actualCopy, expectedCopy)
|
132
|
+
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
'use strict'
|
2
|
+
const test = require('tape')
|
3
|
+
const pino = require('../browser')
|
4
|
+
|
5
|
+
test('set browser opts disabled to true', ({ end, same }) => {
|
6
|
+
const instance = pino({
|
7
|
+
browser: {
|
8
|
+
disabled: true,
|
9
|
+
write (actual) {
|
10
|
+
checkLogObjects(same, actual, [])
|
11
|
+
}
|
12
|
+
}
|
13
|
+
})
|
14
|
+
instance.info('hello world')
|
15
|
+
instance.error('this is an error')
|
16
|
+
instance.fatal('this is fatal')
|
17
|
+
|
18
|
+
end()
|
19
|
+
})
|
20
|
+
|
21
|
+
test('set browser opts disabled to false', ({ end, same }) => {
|
22
|
+
const expected = [
|
23
|
+
{
|
24
|
+
level: 30,
|
25
|
+
msg: 'hello world'
|
26
|
+
},
|
27
|
+
{
|
28
|
+
level: 50,
|
29
|
+
msg: 'this is an error'
|
30
|
+
},
|
31
|
+
{
|
32
|
+
level: 60,
|
33
|
+
msg: 'this is fatal'
|
34
|
+
}
|
35
|
+
]
|
36
|
+
const instance = pino({
|
37
|
+
browser: {
|
38
|
+
disabled: false,
|
39
|
+
write (actual) {
|
40
|
+
checkLogObjects(same, actual, expected.shift())
|
41
|
+
}
|
42
|
+
}
|
43
|
+
})
|
44
|
+
instance.info('hello world')
|
45
|
+
instance.error('this is an error')
|
46
|
+
instance.fatal('this is fatal')
|
47
|
+
|
48
|
+
end()
|
49
|
+
})
|
50
|
+
|
51
|
+
test('disabled is not set in browser opts', ({ end, same }) => {
|
52
|
+
const expected = [
|
53
|
+
{
|
54
|
+
level: 30,
|
55
|
+
msg: 'hello world'
|
56
|
+
},
|
57
|
+
{
|
58
|
+
level: 50,
|
59
|
+
msg: 'this is an error'
|
60
|
+
},
|
61
|
+
{
|
62
|
+
level: 60,
|
63
|
+
msg: 'this is fatal'
|
64
|
+
}
|
65
|
+
]
|
66
|
+
const instance = pino({
|
67
|
+
browser: {
|
68
|
+
write (actual) {
|
69
|
+
checkLogObjects(same, actual, expected.shift())
|
70
|
+
}
|
71
|
+
}
|
72
|
+
})
|
73
|
+
instance.info('hello world')
|
74
|
+
instance.error('this is an error')
|
75
|
+
instance.fatal('this is fatal')
|
76
|
+
|
77
|
+
end()
|
78
|
+
})
|
79
|
+
|
80
|
+
function checkLogObjects (same, actual, expected, is) {
|
81
|
+
const actualCopy = Object.assign({}, actual)
|
82
|
+
const expectedCopy = Object.assign({}, expected)
|
83
|
+
delete actualCopy.time
|
84
|
+
delete expectedCopy.time
|
85
|
+
|
86
|
+
same(actualCopy, expectedCopy)
|
87
|
+
}
|
@@ -0,0 +1,241 @@
|
|
1
|
+
'use strict'
|
2
|
+
const test = require('tape')
|
3
|
+
const pino = require('../browser')
|
4
|
+
|
5
|
+
test('set the level by string', ({ end, same, is }) => {
|
6
|
+
const expected = [
|
7
|
+
{
|
8
|
+
level: 50,
|
9
|
+
msg: 'this is an error'
|
10
|
+
},
|
11
|
+
{
|
12
|
+
level: 60,
|
13
|
+
msg: 'this is fatal'
|
14
|
+
}
|
15
|
+
]
|
16
|
+
const instance = pino({
|
17
|
+
browser: {
|
18
|
+
write (actual) {
|
19
|
+
checkLogObjects(is, same, actual, expected.shift())
|
20
|
+
}
|
21
|
+
}
|
22
|
+
})
|
23
|
+
|
24
|
+
instance.level = 'error'
|
25
|
+
instance.info('hello world')
|
26
|
+
instance.error('this is an error')
|
27
|
+
instance.fatal('this is fatal')
|
28
|
+
|
29
|
+
end()
|
30
|
+
})
|
31
|
+
|
32
|
+
test('set the level by string. init with silent', ({ end, same, is }) => {
|
33
|
+
const expected = [
|
34
|
+
{
|
35
|
+
level: 50,
|
36
|
+
msg: 'this is an error'
|
37
|
+
},
|
38
|
+
{
|
39
|
+
level: 60,
|
40
|
+
msg: 'this is fatal'
|
41
|
+
}
|
42
|
+
]
|
43
|
+
const instance = pino({
|
44
|
+
level: 'silent',
|
45
|
+
browser: {
|
46
|
+
write (actual) {
|
47
|
+
checkLogObjects(is, same, actual, expected.shift())
|
48
|
+
}
|
49
|
+
}
|
50
|
+
})
|
51
|
+
|
52
|
+
instance.level = 'error'
|
53
|
+
instance.info('hello world')
|
54
|
+
instance.error('this is an error')
|
55
|
+
instance.fatal('this is fatal')
|
56
|
+
|
57
|
+
end()
|
58
|
+
})
|
59
|
+
|
60
|
+
test('set the level by string. init with silent and transmit', ({ end, same, is }) => {
|
61
|
+
const expected = [
|
62
|
+
{
|
63
|
+
level: 50,
|
64
|
+
msg: 'this is an error'
|
65
|
+
},
|
66
|
+
{
|
67
|
+
level: 60,
|
68
|
+
msg: 'this is fatal'
|
69
|
+
}
|
70
|
+
]
|
71
|
+
const instance = pino({
|
72
|
+
level: 'silent',
|
73
|
+
browser: {
|
74
|
+
write (actual) {
|
75
|
+
checkLogObjects(is, same, actual, expected.shift())
|
76
|
+
}
|
77
|
+
},
|
78
|
+
transmit: {
|
79
|
+
send () {}
|
80
|
+
}
|
81
|
+
})
|
82
|
+
|
83
|
+
instance.level = 'error'
|
84
|
+
instance.info('hello world')
|
85
|
+
instance.error('this is an error')
|
86
|
+
instance.fatal('this is fatal')
|
87
|
+
|
88
|
+
end()
|
89
|
+
})
|
90
|
+
|
91
|
+
test('set the level via constructor', ({ end, same, is }) => {
|
92
|
+
const expected = [
|
93
|
+
{
|
94
|
+
level: 50,
|
95
|
+
msg: 'this is an error'
|
96
|
+
},
|
97
|
+
{
|
98
|
+
level: 60,
|
99
|
+
msg: 'this is fatal'
|
100
|
+
}
|
101
|
+
]
|
102
|
+
const instance = pino({
|
103
|
+
level: 'error',
|
104
|
+
browser: {
|
105
|
+
write (actual) {
|
106
|
+
checkLogObjects(is, same, actual, expected.shift())
|
107
|
+
}
|
108
|
+
}
|
109
|
+
})
|
110
|
+
|
111
|
+
instance.info('hello world')
|
112
|
+
instance.error('this is an error')
|
113
|
+
instance.fatal('this is fatal')
|
114
|
+
|
115
|
+
end()
|
116
|
+
})
|
117
|
+
|
118
|
+
test('set custom level and use it', ({ end, same, is }) => {
|
119
|
+
const expected = [
|
120
|
+
{
|
121
|
+
level: 31,
|
122
|
+
msg: 'this is a custom level'
|
123
|
+
}
|
124
|
+
]
|
125
|
+
const instance = pino({
|
126
|
+
customLevels: {
|
127
|
+
success: 31
|
128
|
+
},
|
129
|
+
browser: {
|
130
|
+
write (actual) {
|
131
|
+
checkLogObjects(is, same, actual, expected.shift())
|
132
|
+
}
|
133
|
+
}
|
134
|
+
})
|
135
|
+
|
136
|
+
instance.success('this is a custom level')
|
137
|
+
|
138
|
+
end()
|
139
|
+
})
|
140
|
+
|
141
|
+
test('the wrong level throws', ({ end, throws }) => {
|
142
|
+
const instance = pino()
|
143
|
+
throws(() => {
|
144
|
+
instance.level = 'kaboom'
|
145
|
+
})
|
146
|
+
end()
|
147
|
+
})
|
148
|
+
|
149
|
+
test('the wrong level by number throws', ({ end, throws }) => {
|
150
|
+
const instance = pino()
|
151
|
+
throws(() => {
|
152
|
+
instance.levelVal = 55
|
153
|
+
})
|
154
|
+
end()
|
155
|
+
})
|
156
|
+
|
157
|
+
test('exposes level string mappings', ({ end, is }) => {
|
158
|
+
is(pino.levels.values.error, 50)
|
159
|
+
end()
|
160
|
+
})
|
161
|
+
|
162
|
+
test('exposes level number mappings', ({ end, is }) => {
|
163
|
+
is(pino.levels.labels[50], 'error')
|
164
|
+
end()
|
165
|
+
})
|
166
|
+
|
167
|
+
test('returns level integer', ({ end, is }) => {
|
168
|
+
const instance = pino({ level: 'error' })
|
169
|
+
is(instance.levelVal, 50)
|
170
|
+
end()
|
171
|
+
})
|
172
|
+
|
173
|
+
test('silent level via constructor', ({ end, fail }) => {
|
174
|
+
const instance = pino({
|
175
|
+
level: 'silent',
|
176
|
+
browser: {
|
177
|
+
write () {
|
178
|
+
fail('no data should be logged')
|
179
|
+
}
|
180
|
+
}
|
181
|
+
})
|
182
|
+
|
183
|
+
Object.keys(pino.levels.values).forEach((level) => {
|
184
|
+
instance[level]('hello world')
|
185
|
+
})
|
186
|
+
|
187
|
+
end()
|
188
|
+
})
|
189
|
+
|
190
|
+
test('silent level by string', ({ end, fail }) => {
|
191
|
+
const instance = pino({
|
192
|
+
browser: {
|
193
|
+
write () {
|
194
|
+
fail('no data should be logged')
|
195
|
+
}
|
196
|
+
}
|
197
|
+
})
|
198
|
+
|
199
|
+
instance.level = 'silent'
|
200
|
+
|
201
|
+
Object.keys(pino.levels.values).forEach((level) => {
|
202
|
+
instance[level]('hello world')
|
203
|
+
})
|
204
|
+
|
205
|
+
end()
|
206
|
+
})
|
207
|
+
|
208
|
+
test('exposed levels', ({ end, same }) => {
|
209
|
+
same(Object.keys(pino.levels.values), [
|
210
|
+
'fatal',
|
211
|
+
'error',
|
212
|
+
'warn',
|
213
|
+
'info',
|
214
|
+
'debug',
|
215
|
+
'trace'
|
216
|
+
])
|
217
|
+
end()
|
218
|
+
})
|
219
|
+
|
220
|
+
test('exposed labels', ({ end, same }) => {
|
221
|
+
same(Object.keys(pino.levels.labels), [
|
222
|
+
'10',
|
223
|
+
'20',
|
224
|
+
'30',
|
225
|
+
'40',
|
226
|
+
'50',
|
227
|
+
'60'
|
228
|
+
])
|
229
|
+
end()
|
230
|
+
})
|
231
|
+
|
232
|
+
function checkLogObjects (is, same, actual, expected) {
|
233
|
+
is(actual.time <= Date.now(), true, 'time is greater than Date.now()')
|
234
|
+
|
235
|
+
const actualCopy = Object.assign({}, actual)
|
236
|
+
const expectedCopy = Object.assign({}, expected)
|
237
|
+
delete actualCopy.time
|
238
|
+
delete expectedCopy.time
|
239
|
+
|
240
|
+
same(actualCopy, expectedCopy)
|
241
|
+
}
|