tailwind-widgets 5.1.3
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.
- package/LICENSE +24 -0
- package/README.md +113 -0
- package/bin.js +6 -0
- package/bingo-logger.js +211 -0
- package/browser.js +358 -0
- package/docs/api.md +1352 -0
- package/docs/asynchronous.md +102 -0
- package/docs/benchmarks.md +58 -0
- package/docs/browser.md +199 -0
- package/docs/bundling.md +34 -0
- package/docs/child-loggers.md +95 -0
- package/docs/ecosystem.md +74 -0
- package/docs/help.md +305 -0
- package/docs/lts.md +62 -0
- package/docs/pretty.md +101 -0
- package/docs/redaction.md +135 -0
- package/docs/transports.md +792 -0
- package/docs/web.md +257 -0
- package/file.js +12 -0
- package/lib/caller.js +30 -0
- package/lib/deprecations.js +10 -0
- package/lib/levels.js +193 -0
- package/lib/meta.js +5 -0
- package/lib/multistream.js +156 -0
- package/lib/parse.js +14 -0
- package/lib/proto.js +216 -0
- package/lib/redaction.js +118 -0
- package/lib/symbols.js +70 -0
- package/lib/time.js +11 -0
- package/lib/tools.js +563 -0
- package/lib/transport-stream.js +47 -0
- package/lib/transport.js +157 -0
- package/lib/worker-pipeline.js +40 -0
- package/lib/worker.js +54 -0
- package/package.json +131 -0
- package/test/basic.test.js +719 -0
- package/test/broken-pipe.test.js +42 -0
- package/test/browser-levels.test.js +218 -0
- package/test/browser-serializers.test.js +354 -0
- package/test/browser-timestamp.test.js +88 -0
- package/test/browser-transmit.test.js +349 -0
- package/test/browser.test.js +547 -0
- package/test/complex-objects.test.js +34 -0
- package/test/crlf.test.js +32 -0
- package/test/custom-levels.test.js +294 -0
- package/test/error.test.js +374 -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 +28 -0
- package/test/exit.test.js +85 -0
- package/test/final.test.js +237 -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 +29 -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/file15.js +10 -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/eval/node_modules/test.list +3 -0
- package/test/fixtures/pretty/basic.js +6 -0
- package/test/fixtures/pretty/child-with-serializer.js +17 -0
- package/test/fixtures/pretty/child-with-updated-chindings.js +8 -0
- package/test/fixtures/pretty/child.js +8 -0
- package/test/fixtures/pretty/custom-time-label.js +9 -0
- package/test/fixtures/pretty/custom-time.js +9 -0
- package/test/fixtures/pretty/dateformat.js +10 -0
- package/test/fixtures/pretty/error-props.js +9 -0
- package/test/fixtures/pretty/error.js +7 -0
- package/test/fixtures/pretty/final-no-log-before.js +8 -0
- package/test/fixtures/pretty/final-return.js +7 -0
- package/test/fixtures/pretty/final.js +9 -0
- package/test/fixtures/pretty/formatters.js +13 -0
- package/test/fixtures/pretty/level-first.js +6 -0
- package/test/fixtures/pretty/no-time.js +9 -0
- package/test/fixtures/pretty/null-prototype.js +8 -0
- package/test/fixtures/pretty/obj-msg-prop.js +6 -0
- package/test/fixtures/pretty/pretty-factory.js +6 -0
- package/test/fixtures/pretty/redact.js +9 -0
- package/test/fixtures/pretty/serializers.js +17 -0
- package/test/fixtures/pretty/skipped-output.js +13 -0
- package/test/fixtures/pretty/suppress-flush-sync-warning.js +7 -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/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-worker.js +13 -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.es2017.cjs +12 -0
- package/test/fixtures/ts/to-file-transport.es5.cjs +58 -0
- package/test/fixtures/ts/to-file-transport.es6.cjs +23 -0
- package/test/fixtures/ts/to-file-transport.esnext.cjs +12 -0
- package/test/fixtures/ts/to-file-transport.ts +11 -0
- package/test/fixtures/ts/transpile.cjs +40 -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 +97 -0
- package/test/http.test.js +242 -0
- package/test/is-level-enabled.test.js +43 -0
- package/test/jest/basic.spec.js +10 -0
- package/test/levels.test.js +528 -0
- package/test/metadata.test.js +106 -0
- package/test/mixin-merge-strategy.test.js +55 -0
- package/test/mixin.test.js +162 -0
- package/test/multistream.test.js +589 -0
- package/test/pretty.test.js +392 -0
- package/test/redact.test.js +828 -0
- package/test/serializers.test.js +253 -0
- package/test/stdout-protection.test.js +19 -0
- package/test/syncfalse.test.js +118 -0
- package/test/timestamp.test.js +121 -0
- package/test/transport/big.test.js +41 -0
- package/test/transport/bundlers-support.test.js +97 -0
- package/test/transport/caller.test.js +23 -0
- package/test/transport/core.test.js +546 -0
- package/test/transport/core.test.ts +236 -0
- package/test/transport/core.transpiled.test.ts +116 -0
- package/test/transport/module-link.test.js +239 -0
- package/test/transport/pipeline.test.js +36 -0
- package/test/transport/syncfalse.test.js +31 -0
- package/test/transport/targets.test.js +28 -0
- package/test/types/pino-import.test-d.ts +29 -0
- package/test/types/pino-multistream.test-d.ts +26 -0
- package/test/types/pino-top-export.test-d.ts +37 -0
- package/test/types/pino-transport.test-d.ts +122 -0
- package/test/types/pino-type-only.test-d.ts +16 -0
- package/test/types/pino.test-d.ts +341 -0
- package/test/types/pino.ts +42 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { Writable } = require('stream')
|
|
4
|
+
const { test } = require('tap')
|
|
5
|
+
const { join } = require('path')
|
|
6
|
+
const execa = require('execa')
|
|
7
|
+
const writer = require('flush-write-stream')
|
|
8
|
+
const { once } = require('./helper')
|
|
9
|
+
const bingo-logger = require('../')
|
|
10
|
+
const strip = require('strip-ansi')
|
|
11
|
+
|
|
12
|
+
// silence warnings
|
|
13
|
+
process.removeAllListeners('warning')
|
|
14
|
+
|
|
15
|
+
// This test MUST be the first
|
|
16
|
+
test('deprecation', ({ equal, plan }) => {
|
|
17
|
+
plan(1)
|
|
18
|
+
|
|
19
|
+
process.once('warning', function (warning) {
|
|
20
|
+
equal(warning.code, 'PINODEP008')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
bingo-logger({
|
|
24
|
+
prettyPrint: true
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('can be enabled via exported bingo-logger function', async ({ not }) => {
|
|
29
|
+
let actual = ''
|
|
30
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'basic.js')])
|
|
31
|
+
|
|
32
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
33
|
+
actual += s
|
|
34
|
+
cb()
|
|
35
|
+
}))
|
|
36
|
+
await once(child, 'close')
|
|
37
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('can be enabled via exported bingo-logger function with pretty configuration', async ({ not }) => {
|
|
41
|
+
let actual = ''
|
|
42
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'level-first.js')])
|
|
43
|
+
|
|
44
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
45
|
+
actual += s
|
|
46
|
+
cb()
|
|
47
|
+
}))
|
|
48
|
+
await once(child, 'close')
|
|
49
|
+
not(strip(actual).match(/^INFO.*h/), null)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
test('can be enabled via exported bingo-logger function with prettifier', async ({ not }) => {
|
|
53
|
+
let actual = ''
|
|
54
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'pretty-factory.js')])
|
|
55
|
+
|
|
56
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
57
|
+
actual += s
|
|
58
|
+
cb()
|
|
59
|
+
}))
|
|
60
|
+
|
|
61
|
+
await once(child, 'close')
|
|
62
|
+
not(strip(actual).match(/^INFO.*h/), null)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('does not throw error when enabled with stream specified', async ({ doesNotThrow }) => {
|
|
66
|
+
doesNotThrow(() => bingo-logger({ prettyPrint: true }, process.stdout))
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
test('throws when prettyPrint is true but bingo-logger-pretty module is not installed', async ({ throws }) => {
|
|
70
|
+
// bingo-logger pretty *is* installed, and probably also cached, so rather than
|
|
71
|
+
// messing with the filesystem the simplest way to generate a not found
|
|
72
|
+
// error is to simulate it:
|
|
73
|
+
const prettyFactory = require('pino-pretty').prettyFactory
|
|
74
|
+
require('pino-pretty').prettyFactory = () => {
|
|
75
|
+
throw Error('Cannot find module \'bingo-logger-pretty\'')
|
|
76
|
+
}
|
|
77
|
+
throws(() => bingo-logger({ prettyPrint: true }), 'Missing `bingo-logger-pretty` module: `bingo-logger-pretty` must be installed separately')
|
|
78
|
+
require('pino-pretty').prettyFactory = prettyFactory
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('throws when prettyPrint has invalid options', async ({ throws }) => {
|
|
82
|
+
throws(() => bingo-logger({ prettyPrint: { ignore: ['hostname'] } }), 'opts.ignore.split is not a function')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('can send pretty print to custom stream', async ({ equal }) => {
|
|
86
|
+
const dest = new Writable({
|
|
87
|
+
objectMode: true,
|
|
88
|
+
write (formatted, enc) {
|
|
89
|
+
equal(/^INFO.*foo\n$/.test(formatted), true)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const log = bingo-logger({
|
|
94
|
+
prettifier: require('pino-pretty').prettyFactory,
|
|
95
|
+
prettyPrint: {
|
|
96
|
+
levelFirst: true,
|
|
97
|
+
colorize: false
|
|
98
|
+
}
|
|
99
|
+
}, dest)
|
|
100
|
+
log.info('foo')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test('ignores `undefined` from prettifier', async ({ equal }) => {
|
|
104
|
+
let actual = ''
|
|
105
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'skipped-output.js')])
|
|
106
|
+
|
|
107
|
+
child.stdout.pipe(writer((s, enc) => {
|
|
108
|
+
actual += s
|
|
109
|
+
}))
|
|
110
|
+
|
|
111
|
+
await once(child, 'close')
|
|
112
|
+
equal(actual, '')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test('parses and outputs chindings', async ({ equal, not }) => {
|
|
116
|
+
let actual = ''
|
|
117
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'child.js')])
|
|
118
|
+
|
|
119
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
120
|
+
actual += s
|
|
121
|
+
cb()
|
|
122
|
+
}))
|
|
123
|
+
await once(child, 'close')
|
|
124
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null)
|
|
125
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h2/), null)
|
|
126
|
+
not(strip(actual).match(/a: 1/), null)
|
|
127
|
+
not(strip(actual).match(/b: 2/), null)
|
|
128
|
+
equal(strip(actual).match(/a: 1/g).length, 3)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
test('applies updated chindings', async ({ not }) => {
|
|
132
|
+
let actual = ''
|
|
133
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'child-with-updated-chindings.js')])
|
|
134
|
+
|
|
135
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
136
|
+
actual += s
|
|
137
|
+
cb()
|
|
138
|
+
}))
|
|
139
|
+
await once(child, 'close')
|
|
140
|
+
not(strip(actual).match(/foo: 123/), null)
|
|
141
|
+
not(strip(actual).match(/foo: 456/), null)
|
|
142
|
+
not(strip(actual).match(/bar: 789/), null)
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
test('applies formatters', async ({ not }) => {
|
|
146
|
+
let actual = ''
|
|
147
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'formatters.js')])
|
|
148
|
+
|
|
149
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
150
|
+
actual += s
|
|
151
|
+
cb()
|
|
152
|
+
}))
|
|
153
|
+
await once(child, 'close')
|
|
154
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null)
|
|
155
|
+
not(strip(actual).match(/foo: "formatted_bar"/), null)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
test('parses and outputs chindings with serializer', async ({ equal, not }) => {
|
|
159
|
+
let actual = ''
|
|
160
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'child-with-serializer.js')])
|
|
161
|
+
|
|
162
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
163
|
+
actual += s
|
|
164
|
+
cb()
|
|
165
|
+
}))
|
|
166
|
+
await once(child, 'close')
|
|
167
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null)
|
|
168
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h2/), null)
|
|
169
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h3/), null)
|
|
170
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h4/), null)
|
|
171
|
+
not(strip(actual).match(/a: 2/), null)
|
|
172
|
+
not(strip(actual).match(/a: 16/), null)
|
|
173
|
+
not(strip(actual).match(/a: 42/), null)
|
|
174
|
+
equal(strip(actual).match(/a: /g).length, 4)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
test('applies serializers', async ({ not }) => {
|
|
178
|
+
let actual = ''
|
|
179
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'serializers.js')])
|
|
180
|
+
|
|
181
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
182
|
+
actual += s
|
|
183
|
+
cb()
|
|
184
|
+
}))
|
|
185
|
+
await once(child, 'close')
|
|
186
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null)
|
|
187
|
+
not(strip(actual).match(/foo: "bar"/), null)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
test('applies redaction rules', async ({ equal, not }) => {
|
|
191
|
+
let actual = ''
|
|
192
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'redact.js')])
|
|
193
|
+
|
|
194
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
195
|
+
actual += s
|
|
196
|
+
cb()
|
|
197
|
+
}))
|
|
198
|
+
await once(child, 'close')
|
|
199
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null)
|
|
200
|
+
not(strip(actual).match(/\[Redacted\]/), null)
|
|
201
|
+
equal(strip(actual).match(/object/), null)
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
test('dateformat', async ({ not }) => {
|
|
205
|
+
let actual = ''
|
|
206
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'dateformat.js')])
|
|
207
|
+
|
|
208
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
209
|
+
actual += s
|
|
210
|
+
cb()
|
|
211
|
+
}))
|
|
212
|
+
await once(child, 'close')
|
|
213
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): h/), null)
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
test('without timestamp', async ({ not }) => {
|
|
217
|
+
let actual = ''
|
|
218
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'no-time.js')])
|
|
219
|
+
|
|
220
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
221
|
+
actual += s
|
|
222
|
+
cb()
|
|
223
|
+
}))
|
|
224
|
+
await once(child, 'close')
|
|
225
|
+
not(strip(actual).slice(2), '[]')
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
test('with custom timestamp', async ({ equal }) => {
|
|
229
|
+
let actual = ''
|
|
230
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'custom-time.js')])
|
|
231
|
+
|
|
232
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
233
|
+
actual += s
|
|
234
|
+
cb()
|
|
235
|
+
}))
|
|
236
|
+
await once(child, 'close')
|
|
237
|
+
equal(strip(actual).slice(0, 6), '[test]')
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
test('with custom timestamp label', async ({ equal }) => {
|
|
241
|
+
let actual = ''
|
|
242
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'custom-time-label.js')])
|
|
243
|
+
|
|
244
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
245
|
+
actual += s
|
|
246
|
+
cb()
|
|
247
|
+
}))
|
|
248
|
+
await once(child, 'close')
|
|
249
|
+
equal(strip(actual).slice(0, 6), '[test]')
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
test('errors', async ({ not }) => {
|
|
253
|
+
let actual = ''
|
|
254
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'error.js')])
|
|
255
|
+
|
|
256
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
257
|
+
actual += s
|
|
258
|
+
cb()
|
|
259
|
+
}))
|
|
260
|
+
await once(child, 'close')
|
|
261
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): kaboom/), null)
|
|
262
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): with a message/), null)
|
|
263
|
+
not(strip(actual).match(/.*error\.js.*/), null)
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
test('errors with props', async ({ not }) => {
|
|
267
|
+
let actual = ''
|
|
268
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'error-props.js')])
|
|
269
|
+
|
|
270
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
271
|
+
actual += s
|
|
272
|
+
cb()
|
|
273
|
+
}))
|
|
274
|
+
await once(child, 'close')
|
|
275
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): kaboom/), null)
|
|
276
|
+
not(strip(actual).match(/"code": "ENOENT"/), null)
|
|
277
|
+
not(strip(actual).match(/"errno": 1/), null)
|
|
278
|
+
not(strip(actual).match(/.*error-props\.js.*/), null)
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
test('final works with pretty', async ({ not }) => {
|
|
282
|
+
let actual = ''
|
|
283
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'final.js')])
|
|
284
|
+
|
|
285
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
286
|
+
actual += s
|
|
287
|
+
cb()
|
|
288
|
+
}))
|
|
289
|
+
await once(child, 'close')
|
|
290
|
+
not(strip(actual).match(/WARN\s+\(123456 on abcdefghijklmnopqr\): bingo-logger.final with prettyPrint does not support flushing/), null)
|
|
291
|
+
not(strip(actual).match(/INFO\s+\(123456 on abcdefghijklmnopqr\): beforeExit/), null)
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
test('final works when returning a logger', async ({ not }) => {
|
|
295
|
+
let actual = ''
|
|
296
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'final-return.js')])
|
|
297
|
+
|
|
298
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
299
|
+
actual += s
|
|
300
|
+
cb()
|
|
301
|
+
}))
|
|
302
|
+
await once(child, 'close')
|
|
303
|
+
not(strip(actual).match(/WARN\s+\(123456 on abcdefghijklmnopqr\): bingo-logger.final with prettyPrint does not support flushing/), null)
|
|
304
|
+
not(strip(actual).match(/INFO\s+\(123456 on abcdefghijklmnopqr\): after/), null)
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
test('final works without prior logging', async ({ not }) => {
|
|
308
|
+
let actual = ''
|
|
309
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'final-no-log-before.js')])
|
|
310
|
+
|
|
311
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
312
|
+
actual += s
|
|
313
|
+
cb()
|
|
314
|
+
}))
|
|
315
|
+
await once(child, 'close')
|
|
316
|
+
not(strip(actual).match(/WARN\s*: bingo-logger.final with prettyPrint does not support flushing/), null)
|
|
317
|
+
not(strip(actual).match(/INFO\s*\(123456 on abcdefghijklmnopqr\): beforeExit/), null)
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
test('suppress flush sync warning when corresponding option is specified', async ({ equal }) => {
|
|
321
|
+
let actual = ''
|
|
322
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'suppress-flush-sync-warning.js')])
|
|
323
|
+
|
|
324
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
325
|
+
actual += s
|
|
326
|
+
cb()
|
|
327
|
+
}))
|
|
328
|
+
await once(child, 'close')
|
|
329
|
+
equal(strip(actual).match(/WARN\s+\(123456 on abcdefghijklmnopqr\): bingo-logger.final with prettyPrint does not support flushing/), null)
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
test('works as expected with an object with the msg prop', async ({ not }) => {
|
|
333
|
+
let actual = ''
|
|
334
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'obj-msg-prop.js')])
|
|
335
|
+
|
|
336
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
337
|
+
actual += s
|
|
338
|
+
cb()
|
|
339
|
+
}))
|
|
340
|
+
await once(child, 'close')
|
|
341
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): hello/), null)
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
test('handles objects with null prototypes', async ({ not }) => {
|
|
345
|
+
let actual = ''
|
|
346
|
+
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'null-prototype.js')])
|
|
347
|
+
|
|
348
|
+
child.stdout.pipe(writer((s, enc, cb) => {
|
|
349
|
+
actual += s
|
|
350
|
+
cb()
|
|
351
|
+
}))
|
|
352
|
+
await once(child, 'close')
|
|
353
|
+
not(strip(actual).match(/\(123456 on abcdefghijklmnopqr\): hello\s+foo: "bar"/), null)
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
test('should not lose stream metadata for streams with `needsMetadataGsym` flag', async ({ not }) => {
|
|
357
|
+
const dest = new Writable({
|
|
358
|
+
objectMode: true,
|
|
359
|
+
write () {
|
|
360
|
+
not(typeof this.lastLevel === 'undefined', true)
|
|
361
|
+
not(typeof this.lastMsg === 'undefined', true)
|
|
362
|
+
not(typeof this.lastObj === 'undefined', true)
|
|
363
|
+
not(typeof this.lastTime === 'undefined', true)
|
|
364
|
+
not(typeof this.lastLogger === 'undefined', true)
|
|
365
|
+
}
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
dest[bingo-logger.symbols.needsMetadataGsym] = true
|
|
369
|
+
|
|
370
|
+
const log = bingo-logger({
|
|
371
|
+
prettyPrint: true
|
|
372
|
+
}, dest)
|
|
373
|
+
log.info('foo')
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
test('should not add stream metadata for streams without `needsMetadataGsym` flag', async ({ equal }) => {
|
|
377
|
+
const dest = new Writable({
|
|
378
|
+
objectMode: true,
|
|
379
|
+
write () {
|
|
380
|
+
equal(typeof this.lastLevel === 'undefined', true)
|
|
381
|
+
equal(typeof this.lastMsg === 'undefined', true)
|
|
382
|
+
equal(typeof this.lastObj === 'undefined', true)
|
|
383
|
+
equal(typeof this.lastTime === 'undefined', true)
|
|
384
|
+
equal(typeof this.lastLogger === 'undefined', true)
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
const log = bingo-logger({
|
|
389
|
+
prettyPrint: true
|
|
390
|
+
}, dest)
|
|
391
|
+
log.info('foo')
|
|
392
|
+
})
|