@wbce/projen-d9 0.0.28 → 0.1.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.
- package/.jsii +184 -45
- package/API.md +153 -37
- package/CHANGELOG.md +13 -0
- package/README.md +10 -3
- package/docs/D9-plumbing.md +189 -0
- package/lib/cli/atlas.d.ts +10 -0
- package/lib/cli/atlas.js +65 -0
- package/lib/cli/commands/cedar/cedar-format.d.ts +7 -0
- package/lib/cli/commands/cedar/cedar-format.js +75 -0
- package/lib/cli/commands/cedar/cedar-to-d9-translations.d.ts +12 -0
- package/lib/cli/commands/cedar/cedar-to-d9-translations.js +130 -0
- package/lib/cli/commands/cedar/cedar-to-d9.d.ts +57 -0
- package/lib/cli/commands/cedar/cedar-to-d9.js +221 -0
- package/lib/cli/commands/cedar/cedar-translations.d.ts +9 -0
- package/lib/cli/commands/cedar/cedar-translations.js +213 -0
- package/lib/cli/commands/cedar/d9-permission.d.ts +27 -0
- package/lib/cli/commands/cedar/d9-permission.js +45 -0
- package/lib/cli/commands/cedar/d9-to-cedar.d.ts +33 -0
- package/lib/cli/commands/cedar/d9-to-cedar.js +157 -0
- package/lib/cli/commands/cedar/roles-table.d.ts +14 -0
- package/lib/cli/commands/cedar/roles-table.js +29 -0
- package/lib/cli/commands/save/apply-snapshot.js +39 -30
- package/lib/cli/commands/save/check-unsaved.d.ts +9 -0
- package/lib/cli/commands/save/check-unsaved.js +81 -0
- package/lib/cli/commands/save/env.d.ts +33 -0
- package/lib/cli/commands/save/env.js +109 -0
- package/lib/cli/commands/save/save-snapshot.d.ts +9 -0
- package/lib/cli/commands/save/save-snapshot.js +232 -0
- package/lib/cli/commands/save/sync-files.d.ts +5 -0
- package/lib/cli/commands/save/sync-files.js +46 -0
- package/lib/cli/commands/save/transfer.d.ts +18 -0
- package/lib/cli/commands/save/transfer.js +96 -0
- package/lib/cli/commands/save/utils.d.ts +5 -0
- package/lib/cli/commands/save/utils.js +33 -3
- package/lib/cli/commands/sync.js +4 -3
- package/lib/cli/index.js +65 -25
- package/lib/cli/logger.d.ts +2 -0
- package/lib/cli/logger.js +10 -0
- package/lib/cli/plumbing-config.d.ts +11 -0
- package/lib/cli/plumbing-config.js +13 -0
- package/lib/index.d.ts +44 -5
- package/lib/index.js +54 -41
- package/node_modules/@cedar-policy/cedar-wasm/README.md +181 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/README.md +181 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.d.ts +427 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.js +9 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.js +434 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm +0 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm.d.ts +34 -0
- package/node_modules/@cedar-policy/cedar-wasm/esm/package.json +23 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/README.md +181 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.d.ts +427 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.js +463 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm +0 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm.d.ts +34 -0
- package/node_modules/@cedar-policy/cedar-wasm/nodejs/package.json +18 -0
- package/node_modules/@cedar-policy/cedar-wasm/package.json +53 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/README.md +181 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.d.ts +486 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.js +534 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm +0 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm.d.ts +34 -0
- package/node_modules/@cedar-policy/cedar-wasm/web/package.json +21 -0
- package/node_modules/@types/node/README.md +5 -6
- package/node_modules/@types/node/assert/strict.d.ts +111 -0
- package/node_modules/@types/node/assert.d.ts +1040 -79
- package/node_modules/@types/node/async_hooks.d.ts +476 -119
- package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
- package/node_modules/@types/node/buffer.d.ts +1925 -13
- package/node_modules/@types/node/child_process.d.ts +1204 -235
- package/node_modules/@types/node/cluster.d.ts +455 -137
- package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
- package/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
- package/node_modules/@types/node/console.d.ts +450 -1
- package/node_modules/@types/node/constants.d.ts +20 -447
- package/node_modules/@types/node/crypto.d.ts +3962 -600
- package/node_modules/@types/node/dgram.d.ts +515 -33
- package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
- package/node_modules/@types/node/dns/promises.d.ts +503 -0
- package/node_modules/@types/node/dns.d.ts +798 -247
- package/node_modules/@types/node/domain.d.ts +164 -10
- package/node_modules/@types/node/events.d.ts +954 -25
- package/node_modules/@types/node/fs/promises.d.ts +1295 -0
- package/node_modules/@types/node/fs.d.ts +3463 -1569
- package/node_modules/@types/node/globals.d.ts +98 -1277
- package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/node_modules/@types/node/http.d.ts +1933 -300
- package/node_modules/@types/node/http2.d.ts +1946 -254
- package/node_modules/@types/node/https.d.ts +557 -134
- package/node_modules/@types/node/index.d.ts +54 -48
- package/node_modules/@types/node/inspector.d.ts +227 -3014
- package/node_modules/@types/node/inspector.generated.d.ts +4052 -0
- package/node_modules/@types/node/module.d.ts +890 -2
- package/node_modules/@types/node/net.d.ts +872 -105
- package/node_modules/@types/node/os.d.ts +452 -209
- package/node_modules/@types/node/package.json +78 -128
- package/node_modules/@types/node/path.d.ts +196 -155
- package/node_modules/@types/node/perf_hooks.d.ts +829 -120
- package/node_modules/@types/node/process.d.ts +2072 -3
- package/node_modules/@types/node/punycode.d.ts +69 -27
- package/node_modules/@types/node/querystring.d.ts +132 -9
- package/node_modules/@types/node/readline/promises.d.ts +161 -0
- package/node_modules/@types/node/readline.d.ts +485 -49
- package/node_modules/@types/node/repl.d.ts +121 -83
- package/node_modules/@types/node/sea.d.ts +153 -0
- package/node_modules/@types/node/sqlite.d.ts +721 -0
- package/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +622 -0
- package/node_modules/@types/node/stream.d.ts +1470 -140
- package/node_modules/@types/node/string_decoder.d.ts +64 -4
- package/node_modules/@types/node/test.d.ts +2163 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +284 -13
- package/node_modules/@types/node/tls.d.ts +850 -244
- package/node_modules/@types/node/trace_events.d.ts +147 -11
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +97 -0
- package/node_modules/@types/node/tty.d.ts +160 -18
- package/node_modules/@types/node/url.d.ts +890 -53
- package/node_modules/@types/node/util.d.ts +2566 -160
- package/node_modules/@types/node/v8.d.ts +806 -83
- package/node_modules/@types/node/vm.d.ts +932 -44
- package/node_modules/@types/node/wasi.d.ts +148 -22
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/node_modules/@types/node/web-globals/navigator.d.ts +22 -0
- package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/node_modules/@types/node/worker_threads.d.ts +657 -80
- package/node_modules/@types/node/zlib.d.ts +510 -119
- package/node_modules/pino/.nojekyll +0 -0
- package/node_modules/pino/.prettierignore +1 -0
- package/node_modules/pino/CNAME +1 -0
- package/node_modules/pino/CONTRIBUTING.md +34 -0
- package/node_modules/pino/LICENSE +21 -0
- package/node_modules/pino/README.md +177 -0
- package/node_modules/pino/SECURITY.md +103 -0
- package/node_modules/pino/benchmarks/basic.bench.js +95 -0
- package/node_modules/pino/benchmarks/child-child.bench.js +52 -0
- package/node_modules/pino/benchmarks/child-creation.bench.js +73 -0
- package/node_modules/pino/benchmarks/child.bench.js +62 -0
- package/node_modules/pino/benchmarks/deep-object.bench.js +88 -0
- package/node_modules/pino/benchmarks/formatters.bench.js +50 -0
- package/node_modules/pino/benchmarks/internal/custom-levels.js +67 -0
- package/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js +76 -0
- package/node_modules/pino/benchmarks/internal/just-pino.bench.js +182 -0
- package/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js +75 -0
- package/node_modules/pino/benchmarks/internal/redact.bench.js +86 -0
- package/node_modules/pino/benchmarks/long-string.bench.js +81 -0
- package/node_modules/pino/benchmarks/multi-arg.bench.js +193 -0
- package/node_modules/pino/benchmarks/multistream.js +98 -0
- package/node_modules/pino/benchmarks/object.bench.js +82 -0
- package/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js +36 -0
- package/node_modules/pino/benchmarks/utils/runbench.js +138 -0
- package/node_modules/pino/benchmarks/utils/wrap-log-level.js +55 -0
- package/node_modules/pino/bin.js +6 -0
- package/node_modules/pino/browser.js +607 -0
- package/node_modules/pino/build/sync-version.js +25 -0
- package/node_modules/pino/docs/api.md +1664 -0
- package/node_modules/pino/docs/asynchronous.md +55 -0
- package/node_modules/pino/docs/benchmarks.md +55 -0
- package/node_modules/pino/docs/browser.md +341 -0
- package/node_modules/pino/docs/bundling.md +40 -0
- package/node_modules/pino/docs/child-loggers.md +116 -0
- package/node_modules/pino/docs/diagnostics.md +16 -0
- package/node_modules/pino/docs/ecosystem.md +87 -0
- package/node_modules/pino/docs/help.md +353 -0
- package/node_modules/pino/docs/lts.md +93 -0
- package/node_modules/pino/docs/pretty.md +38 -0
- package/node_modules/pino/docs/redaction.md +130 -0
- package/node_modules/pino/docs/transports.md +1447 -0
- package/node_modules/pino/docs/web.md +306 -0
- package/node_modules/pino/eslint.config.js +36 -0
- package/node_modules/pino/examples/basic.js +43 -0
- package/node_modules/pino/examples/transport.js +68 -0
- package/node_modules/pino/favicon.ico +0 -0
- package/node_modules/pino/file.js +12 -0
- package/node_modules/pino/inc-version.sh +42 -0
- package/node_modules/pino/index.html +55 -0
- package/node_modules/pino/lib/caller.js +40 -0
- package/node_modules/pino/lib/constants.js +28 -0
- package/node_modules/pino/lib/deprecations.js +8 -0
- package/node_modules/pino/lib/levels.js +241 -0
- package/node_modules/pino/lib/meta.js +3 -0
- package/node_modules/pino/lib/multistream.js +211 -0
- package/node_modules/pino/lib/proto.js +256 -0
- package/node_modules/pino/lib/redaction.js +119 -0
- package/node_modules/pino/lib/symbols.js +76 -0
- package/node_modules/pino/lib/time.js +39 -0
- package/node_modules/pino/lib/tools.js +427 -0
- package/node_modules/pino/lib/transport-stream.js +56 -0
- package/node_modules/pino/lib/transport.js +302 -0
- package/node_modules/pino/lib/worker.js +197 -0
- package/node_modules/pino/package.json +112 -0
- package/node_modules/pino/pino.d.ts +881 -0
- package/node_modules/pino/pino.js +259 -0
- package/node_modules/pino/test/basic.test.js +952 -0
- package/node_modules/pino/test/broken-pipe.test.js +59 -0
- package/node_modules/pino/test/browser-bindings.test.js +114 -0
- package/node_modules/pino/test/browser-child.test.js +132 -0
- package/node_modules/pino/test/browser-disabled.test.js +87 -0
- package/node_modules/pino/test/browser-early-console-freeze.test.js +12 -0
- package/node_modules/pino/test/browser-is-level-enabled.test.js +101 -0
- package/node_modules/pino/test/browser-levels.test.js +241 -0
- package/node_modules/pino/test/browser-redaction.test.js +264 -0
- package/node_modules/pino/test/browser-serializers.test.js +352 -0
- package/node_modules/pino/test/browser-set-bindings.test.js +99 -0
- package/node_modules/pino/test/browser-timestamp.test.js +88 -0
- package/node_modules/pino/test/browser-transmit.test.js +417 -0
- package/node_modules/pino/test/browser.test.js +698 -0
- package/node_modules/pino/test/caller.test.js +20 -0
- package/node_modules/pino/test/complex-objects.test.js +36 -0
- package/node_modules/pino/test/crlf.test.js +34 -0
- package/node_modules/pino/test/custom-levels.test.js +267 -0
- package/node_modules/pino/test/diagnostics.test.js +107 -0
- package/node_modules/pino/test/error-key.test.js +37 -0
- package/node_modules/pino/test/error.test.js +403 -0
- package/node_modules/pino/test/escaping.test.js +110 -0
- package/node_modules/pino/test/esm/esm.mjs +14 -0
- package/node_modules/pino/test/esm/index.test.js +21 -0
- package/node_modules/pino/test/esm/named-exports.mjs +29 -0
- package/node_modules/pino/test/exit.test.js +79 -0
- package/node_modules/pino/test/fixtures/broken-pipe/basic.js +9 -0
- package/node_modules/pino/test/fixtures/broken-pipe/destination.js +10 -0
- package/node_modules/pino/test/fixtures/broken-pipe/syncfalse.js +12 -0
- package/node_modules/pino/test/fixtures/caller-loop.js +6 -0
- package/node_modules/pino/test/fixtures/console-transport.js +13 -0
- package/node_modules/pino/test/fixtures/crashing-transport.js +13 -0
- package/node_modules/pino/test/fixtures/default-exit.js +8 -0
- package/node_modules/pino/test/fixtures/destination-exit.js +8 -0
- package/node_modules/pino/test/fixtures/eval/index.js +13 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/14-files.js +3 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/2-files.js +3 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file1.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file10.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file11.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file12.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file13.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file14.js +11 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file2.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file3.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file4.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file5.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file6.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file7.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file8.js +5 -0
- package/node_modules/pino/test/fixtures/eval/node_modules/file9.js +5 -0
- package/node_modules/pino/test/fixtures/noop-transport.js +10 -0
- package/node_modules/pino/test/fixtures/pretty/null-prototype.js +8 -0
- package/node_modules/pino/test/fixtures/stdout-hack-protection.js +11 -0
- package/node_modules/pino/test/fixtures/syncfalse-child.js +6 -0
- package/node_modules/pino/test/fixtures/syncfalse-exit.js +9 -0
- package/node_modules/pino/test/fixtures/syncfalse-flush-exit.js +10 -0
- package/node_modules/pino/test/fixtures/syncfalse.js +6 -0
- package/node_modules/pino/test/fixtures/syntax-error-esm.mjs +2 -0
- package/node_modules/pino/test/fixtures/to-file-transport-with-transform.js +20 -0
- package/node_modules/pino/test/fixtures/to-file-transport.js +13 -0
- package/node_modules/pino/test/fixtures/to-file-transport.mjs +8 -0
- package/node_modules/pino/test/fixtures/transport/index.js +12 -0
- package/node_modules/pino/test/fixtures/transport/package.json +5 -0
- package/node_modules/pino/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
- package/node_modules/pino/test/fixtures/transport-exit-immediately.js +11 -0
- package/node_modules/pino/test/fixtures/transport-exit-on-ready.js +12 -0
- package/node_modules/pino/test/fixtures/transport-invalid-node-options.js +26 -0
- package/node_modules/pino/test/fixtures/transport-main.js +9 -0
- package/node_modules/pino/test/fixtures/transport-many-lines.js +29 -0
- package/node_modules/pino/test/fixtures/transport-preload-main.mjs +13 -0
- package/node_modules/pino/test/fixtures/transport-preload.mjs +13 -0
- package/node_modules/pino/test/fixtures/transport-string-stdout.js +9 -0
- package/node_modules/pino/test/fixtures/transport-transform.js +21 -0
- package/node_modules/pino/test/fixtures/transport-uses-pino-config.js +33 -0
- package/node_modules/pino/test/fixtures/transport-with-on-exit.js +12 -0
- package/node_modules/pino/test/fixtures/transport-worker-data.js +19 -0
- package/node_modules/pino/test/fixtures/transport-worker-name.js +24 -0
- package/node_modules/pino/test/fixtures/transport-worker.js +15 -0
- package/node_modules/pino/test/fixtures/transport-wrong-export-type.js +3 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport-native.mts +15 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
- package/node_modules/pino/test/fixtures/ts/to-file-transport.ts +11 -0
- package/node_modules/pino/test/fixtures/ts/transpile.cjs +36 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-immediately.ts +10 -0
- package/node_modules/pino/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
- package/node_modules/pino/test/fixtures/ts/transport-main.ts +8 -0
- package/node_modules/pino/test/fixtures/ts/transport-string-stdout.ts +8 -0
- package/node_modules/pino/test/fixtures/ts/transport-worker.ts +14 -0
- package/node_modules/pino/test/formatters.test.js +364 -0
- package/node_modules/pino/test/helper.d.ts +4 -0
- package/node_modules/pino/test/helper.js +159 -0
- package/node_modules/pino/test/hooks.test.js +114 -0
- package/node_modules/pino/test/http.test.js +214 -0
- package/node_modules/pino/test/internals/version.test.js +17 -0
- package/node_modules/pino/test/is-level-enabled.test.js +179 -0
- package/node_modules/pino/test/jest/basic.spec.js +10 -0
- package/node_modules/pino/test/levels.test.js +810 -0
- package/node_modules/pino/test/metadata.test.js +120 -0
- package/node_modules/pino/test/mixin-merge-strategy.test.js +57 -0
- package/node_modules/pino/test/mixin.test.js +241 -0
- package/node_modules/pino/test/multistream.test.js +793 -0
- package/node_modules/pino/test/redact.test.js +923 -0
- package/node_modules/pino/test/serializers.test.js +257 -0
- package/node_modules/pino/test/smoke.js +59 -0
- package/node_modules/pino/test/stdout-protection.test.js +41 -0
- package/node_modules/pino/test/syncfalse.test.js +186 -0
- package/node_modules/pino/test/timestamp-nano.test.js +37 -0
- package/node_modules/pino/test/timestamp.test.js +124 -0
- package/node_modules/pino/test/transport/big.test.js +42 -0
- package/node_modules/pino/test/transport/bundlers-support.test.js +99 -0
- package/node_modules/pino/test/transport/caller.test.js +24 -0
- package/node_modules/pino/test/transport/core.test.js +818 -0
- package/node_modules/pino/test/transport/core.transpiled.test.ts +114 -0
- package/node_modules/pino/test/transport/crash.test.js +36 -0
- package/node_modules/pino/test/transport/module-link.test.js +241 -0
- package/node_modules/pino/test/transport/native-type-stripping.test.mjs +151 -0
- package/node_modules/pino/test/transport/node-options.test.js +116 -0
- package/node_modules/pino/test/transport/pipeline.test.js +137 -0
- package/node_modules/pino/test/transport/preload.test.js +54 -0
- package/node_modules/pino/test/transport/repl.test.js +15 -0
- package/node_modules/pino/test/transport/sync-false.test.js +79 -0
- package/node_modules/pino/test/transport/sync-true.test.js +57 -0
- package/node_modules/pino/test/transport/targets.test.js +48 -0
- package/node_modules/pino/test/transport/uses-pino-config.test.js +166 -0
- package/node_modules/pino/test/transport-stream.test.js +40 -0
- package/node_modules/pino/test/types/pino-import.tst.cts +30 -0
- package/node_modules/pino/test/types/pino-import.tst.js +73 -0
- package/node_modules/pino/test/types/pino-multistream.tst.ts +49 -0
- package/node_modules/pino/test/types/pino-top-export.tst.ts +32 -0
- package/node_modules/pino/test/types/pino-transport.tst.ts +171 -0
- package/node_modules/pino/test/types/pino-type-only.tst.ts +77 -0
- package/node_modules/pino/test/types/pino.ts +98 -0
- package/node_modules/pino/test/types/pino.tst.ts +681 -0
- package/node_modules/pino/test/types/tsconfig.json +10 -0
- package/node_modules/pino/tsconfig.json +14 -0
- package/node_modules/pino-pretty/.borp.yaml +6 -0
- package/node_modules/pino-pretty/.editorconfig +13 -0
- package/node_modules/pino-pretty/.github/dependabot.yml +13 -0
- package/node_modules/pino-pretty/.github/workflows/ci.yml +83 -0
- package/node_modules/pino-pretty/LICENSE +21 -0
- package/node_modules/pino-pretty/Readme.md +425 -0
- package/node_modules/pino-pretty/SECURITY.md +146 -0
- package/node_modules/pino-pretty/benchmark.js +105 -0
- package/node_modules/pino-pretty/bin.js +113 -0
- package/node_modules/pino-pretty/demo.png +0 -0
- package/node_modules/pino-pretty/docs/help.md +24 -0
- package/node_modules/pino-pretty/eslint.config.js +5 -0
- package/node_modules/pino-pretty/help/help.txt +68 -0
- package/node_modules/pino-pretty/index.d.ts +227 -0
- package/node_modules/pino-pretty/index.js +234 -0
- package/node_modules/pino-pretty/lib/colors.js +134 -0
- package/node_modules/pino-pretty/lib/colors.test.js +132 -0
- package/node_modules/pino-pretty/lib/constants.js +55 -0
- package/node_modules/pino-pretty/lib/pretty.js +171 -0
- package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.js +69 -0
- package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.test.js +84 -0
- package/node_modules/pino-pretty/lib/utils/create-date.js +26 -0
- package/node_modules/pino-pretty/lib/utils/create-date.test.js +20 -0
- package/node_modules/pino-pretty/lib/utils/delete-log-property.js +28 -0
- package/node_modules/pino-pretty/lib/utils/delete-log-property.test.js +31 -0
- package/node_modules/pino-pretty/lib/utils/filter-log.js +99 -0
- package/node_modules/pino-pretty/lib/utils/filter-log.test.js +265 -0
- package/node_modules/pino-pretty/lib/utils/format-time.js +66 -0
- package/node_modules/pino-pretty/lib/utils/format-time.test.js +71 -0
- package/node_modules/pino-pretty/lib/utils/get-level-label-data.js +29 -0
- package/node_modules/pino-pretty/lib/utils/get-property-value.js +30 -0
- package/node_modules/pino-pretty/lib/utils/get-property-value.test.js +31 -0
- package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.js +38 -0
- package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.test.js +45 -0
- package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.js +39 -0
- package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.test.js +47 -0
- package/node_modules/pino-pretty/lib/utils/index.js +108 -0
- package/node_modules/pino-pretty/lib/utils/index.test.js +37 -0
- package/node_modules/pino-pretty/lib/utils/interpret-conditionals.js +41 -0
- package/node_modules/pino-pretty/lib/utils/interpret-conditionals.test.js +84 -0
- package/node_modules/pino-pretty/lib/utils/is-object.js +7 -0
- package/node_modules/pino-pretty/lib/utils/is-object.test.js +10 -0
- package/node_modules/pino-pretty/lib/utils/is-valid-date.js +14 -0
- package/node_modules/pino-pretty/lib/utils/is-valid-date.test.js +16 -0
- package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.js +29 -0
- package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.test.js +16 -0
- package/node_modules/pino-pretty/lib/utils/noop.js +3 -0
- package/node_modules/pino-pretty/lib/utils/noop.test.js +12 -0
- package/node_modules/pino-pretty/lib/utils/parse-factory-options.js +171 -0
- package/node_modules/pino-pretty/lib/utils/prettify-error-log.js +76 -0
- package/node_modules/pino-pretty/lib/utils/prettify-error-log.test.js +143 -0
- package/node_modules/pino-pretty/lib/utils/prettify-error.js +54 -0
- package/node_modules/pino-pretty/lib/utils/prettify-error.test.js +25 -0
- package/node_modules/pino-pretty/lib/utils/prettify-level.js +41 -0
- package/node_modules/pino-pretty/lib/utils/prettify-level.test.js +70 -0
- package/node_modules/pino-pretty/lib/utils/prettify-message.js +65 -0
- package/node_modules/pino-pretty/lib/utils/prettify-message.test.js +287 -0
- package/node_modules/pino-pretty/lib/utils/prettify-metadata.js +75 -0
- package/node_modules/pino-pretty/lib/utils/prettify-metadata.test.js +170 -0
- package/node_modules/pino-pretty/lib/utils/prettify-object.js +115 -0
- package/node_modules/pino-pretty/lib/utils/prettify-object.test.js +217 -0
- package/node_modules/pino-pretty/lib/utils/prettify-time.js +43 -0
- package/node_modules/pino-pretty/lib/utils/prettify-time.test.js +264 -0
- package/node_modules/pino-pretty/lib/utils/split-property-key.js +49 -0
- package/node_modules/pino-pretty/lib/utils/split-property-key.test.js +29 -0
- package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.js +18 -0
- package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.test.js +9 -0
- package/node_modules/pino-pretty/package.json +64 -0
- package/node_modules/pino-pretty/test/basic.test.js +1305 -0
- package/node_modules/pino-pretty/test/boolean-options.test.js +228 -0
- package/node_modules/pino-pretty/test/cli-rc.test.js +275 -0
- package/node_modules/pino-pretty/test/cli.test.js +360 -0
- package/node_modules/pino-pretty/test/crlf.test.js +33 -0
- package/node_modules/pino-pretty/test/error-objects.test.js +494 -0
- package/node_modules/pino-pretty/test/example/example.js +33 -0
- package/node_modules/pino-pretty/test/helper.js +19 -0
- package/node_modules/pino-pretty/test/types/exports.tst.ts +15 -0
- package/node_modules/pino-pretty/test/types/pino-pretty.tst.ts +140 -0
- package/node_modules/pino-pretty/test/types/tsconfig.json +9 -0
- package/package.json +12 -5
- package/lib/cli/commands/init.d.ts +0 -1
- package/lib/cli/commands/init.js +0 -8
- package/node_modules/@types/node/globals.global.d.ts +0 -1
|
@@ -0,0 +1,1305 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
process.env.TZ = 'UTC'
|
|
4
|
+
|
|
5
|
+
const os = require('node:os')
|
|
6
|
+
const fs = require('node:fs')
|
|
7
|
+
const { join } = require('node:path')
|
|
8
|
+
const { describe, test, beforeEach, afterEach } = require('node:test')
|
|
9
|
+
const { Writable } = require('node:stream')
|
|
10
|
+
const match = require('@jsumners/assert-match')
|
|
11
|
+
const pino = require('pino')
|
|
12
|
+
const dateformat = require('dateformat')
|
|
13
|
+
const rimraf = require('rimraf')
|
|
14
|
+
const SonicBoom = require('sonic-boom')
|
|
15
|
+
const semver = require('semver')
|
|
16
|
+
|
|
17
|
+
const pinoPretty = require('..')
|
|
18
|
+
const _prettyFactory = pinoPretty.prettyFactory
|
|
19
|
+
|
|
20
|
+
// Disable pino warnings
|
|
21
|
+
process.removeAllListeners('warning')
|
|
22
|
+
|
|
23
|
+
function prettyFactory (opts) {
|
|
24
|
+
if (!opts) {
|
|
25
|
+
opts = { colorize: false }
|
|
26
|
+
} else if (!Object.prototype.hasOwnProperty.call(opts, 'colorize')) {
|
|
27
|
+
opts.colorize = false
|
|
28
|
+
}
|
|
29
|
+
return _prettyFactory(opts)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const Empty = function () {}
|
|
33
|
+
Empty.prototype = Object.create(null)
|
|
34
|
+
|
|
35
|
+
// All dates are computed from 'Fri, 30 Mar 2018 17:35:28 GMT'
|
|
36
|
+
const epoch = 1522431328992
|
|
37
|
+
const formattedEpoch = '17:35:28.992'
|
|
38
|
+
const pid = process.pid
|
|
39
|
+
const hostname = os.hostname()
|
|
40
|
+
|
|
41
|
+
describe('basic prettifier tests', () => {
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
Date.originalNow = Date.now
|
|
44
|
+
Date.now = () => epoch
|
|
45
|
+
})
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
Date.now = Date.originalNow
|
|
48
|
+
delete Date.originalNow
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('preserves output if not valid JSON', (t) => {
|
|
52
|
+
t.plan(1)
|
|
53
|
+
const pretty = prettyFactory()
|
|
54
|
+
const formatted = pretty('this is not json\nit\'s just regular output\n')
|
|
55
|
+
t.assert.strictEqual(formatted, 'this is not json\nit\'s just regular output\n\n')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('formats a line without any extra options', (t) => {
|
|
59
|
+
t.plan(1)
|
|
60
|
+
const pretty = prettyFactory()
|
|
61
|
+
const log = pino({}, new Writable({
|
|
62
|
+
write (chunk, enc, cb) {
|
|
63
|
+
const formatted = pretty(chunk.toString())
|
|
64
|
+
t.assert.strictEqual(
|
|
65
|
+
formatted,
|
|
66
|
+
`[${formattedEpoch}] INFO (${pid}): foo\n`
|
|
67
|
+
)
|
|
68
|
+
cb()
|
|
69
|
+
}
|
|
70
|
+
}))
|
|
71
|
+
log.info('foo')
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
test('will add color codes', (t) => {
|
|
75
|
+
t.plan(1)
|
|
76
|
+
const pretty = prettyFactory({ colorize: true })
|
|
77
|
+
const log = pino({}, new Writable({
|
|
78
|
+
write (chunk, enc, cb) {
|
|
79
|
+
const formatted = pretty(chunk.toString())
|
|
80
|
+
t.assert.strictEqual(
|
|
81
|
+
formatted,
|
|
82
|
+
`[${formattedEpoch}] \u001B[32mINFO\u001B[39m (${pid}): \u001B[36mfoo\u001B[39m\n`
|
|
83
|
+
)
|
|
84
|
+
cb()
|
|
85
|
+
}
|
|
86
|
+
}))
|
|
87
|
+
log.info('foo')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
test('will omit color codes from objects when colorizeObjects = false', (t) => {
|
|
91
|
+
t.plan(1)
|
|
92
|
+
const pretty = prettyFactory({ colorize: true, singleLine: true, colorizeObjects: false })
|
|
93
|
+
const log = pino({}, new Writable({
|
|
94
|
+
write (chunk, enc, cb) {
|
|
95
|
+
const formatted = pretty(chunk.toString())
|
|
96
|
+
t.assert.strictEqual(
|
|
97
|
+
formatted,
|
|
98
|
+
`[${formattedEpoch}] \u001B[32mINFO\u001B[39m (${pid}): \u001B[36mfoo\u001B[39m {"foo":"bar"}\n`
|
|
99
|
+
)
|
|
100
|
+
cb()
|
|
101
|
+
}
|
|
102
|
+
}))
|
|
103
|
+
log.info({ foo: 'bar' }, 'foo')
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
test('can swap date and level position', (t) => {
|
|
107
|
+
t.plan(1)
|
|
108
|
+
const destination = new Writable({
|
|
109
|
+
write (formatted, enc, cb) {
|
|
110
|
+
t.assert.strictEqual(
|
|
111
|
+
formatted.toString(),
|
|
112
|
+
`INFO [${formattedEpoch}] (${pid}): foo\n`
|
|
113
|
+
)
|
|
114
|
+
cb()
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
const pretty = pinoPretty({
|
|
118
|
+
destination,
|
|
119
|
+
levelFirst: true,
|
|
120
|
+
colorize: false
|
|
121
|
+
})
|
|
122
|
+
const log = pino({}, pretty)
|
|
123
|
+
log.info('foo')
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
test('can print message key value when its a string', (t) => {
|
|
127
|
+
t.plan(1)
|
|
128
|
+
const pretty = prettyFactory()
|
|
129
|
+
const log = pino({}, new Writable({
|
|
130
|
+
write (chunk, enc, cb) {
|
|
131
|
+
const formatted = pretty(chunk.toString())
|
|
132
|
+
t.assert.strictEqual(
|
|
133
|
+
formatted,
|
|
134
|
+
`[${formattedEpoch}] INFO (${pid}): baz\n`
|
|
135
|
+
)
|
|
136
|
+
cb()
|
|
137
|
+
}
|
|
138
|
+
}))
|
|
139
|
+
log.info('baz')
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
test('can print message key value when its a number', (t) => {
|
|
143
|
+
t.plan(1)
|
|
144
|
+
const pretty = prettyFactory()
|
|
145
|
+
const log = pino({}, new Writable({
|
|
146
|
+
write (chunk, enc, cb) {
|
|
147
|
+
const formatted = pretty(chunk.toString())
|
|
148
|
+
t.assert.strictEqual(
|
|
149
|
+
formatted,
|
|
150
|
+
`[${formattedEpoch}] INFO (${pid}): 42\n`
|
|
151
|
+
)
|
|
152
|
+
cb()
|
|
153
|
+
}
|
|
154
|
+
}))
|
|
155
|
+
log.info(42)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
test('can print message key value when its a Number(0)', (t) => {
|
|
159
|
+
t.plan(1)
|
|
160
|
+
const pretty = prettyFactory()
|
|
161
|
+
const log = pino({}, new Writable({
|
|
162
|
+
write (chunk, enc, cb) {
|
|
163
|
+
const formatted = pretty(chunk.toString())
|
|
164
|
+
t.assert.strictEqual(
|
|
165
|
+
formatted,
|
|
166
|
+
`[${formattedEpoch}] INFO (${pid}): 0\n`
|
|
167
|
+
)
|
|
168
|
+
cb()
|
|
169
|
+
}
|
|
170
|
+
}))
|
|
171
|
+
log.info(0)
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
test('can print message key value when its a boolean', (t) => {
|
|
175
|
+
t.plan(1)
|
|
176
|
+
const pretty = prettyFactory()
|
|
177
|
+
const log = pino({}, new Writable({
|
|
178
|
+
write (chunk, enc, cb) {
|
|
179
|
+
const formatted = pretty(chunk.toString())
|
|
180
|
+
t.assert.strictEqual(
|
|
181
|
+
formatted,
|
|
182
|
+
`[${formattedEpoch}] INFO (${pid}): true\n`
|
|
183
|
+
)
|
|
184
|
+
cb()
|
|
185
|
+
}
|
|
186
|
+
}))
|
|
187
|
+
log.info(true)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
test('can use different message keys', (t) => {
|
|
191
|
+
t.plan(1)
|
|
192
|
+
const pretty = prettyFactory({ messageKey: 'bar' })
|
|
193
|
+
const log = pino({}, new Writable({
|
|
194
|
+
write (chunk, enc, cb) {
|
|
195
|
+
const formatted = pretty(chunk.toString())
|
|
196
|
+
t.assert.strictEqual(
|
|
197
|
+
formatted,
|
|
198
|
+
`[${formattedEpoch}] INFO (${pid}): baz\n`
|
|
199
|
+
)
|
|
200
|
+
cb()
|
|
201
|
+
}
|
|
202
|
+
}))
|
|
203
|
+
log.info({ bar: 'baz' })
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
test('can use different level keys', (t) => {
|
|
207
|
+
t.plan(1)
|
|
208
|
+
const pretty = prettyFactory({ levelKey: 'bar' })
|
|
209
|
+
const log = pino({}, new Writable({
|
|
210
|
+
write (chunk, enc, cb) {
|
|
211
|
+
const formatted = pretty(chunk.toString())
|
|
212
|
+
t.assert.strictEqual(
|
|
213
|
+
formatted,
|
|
214
|
+
`[${formattedEpoch}] WARN (${pid}): foo\n`
|
|
215
|
+
)
|
|
216
|
+
cb()
|
|
217
|
+
}
|
|
218
|
+
}))
|
|
219
|
+
log.info({ msg: 'foo', bar: 'warn' })
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
test('can use nested level keys', (t) => {
|
|
223
|
+
t.plan(1)
|
|
224
|
+
const pretty = prettyFactory({ levelKey: 'log\\.level' })
|
|
225
|
+
const log = pino({}, new Writable({
|
|
226
|
+
write (chunk, enc, cb) {
|
|
227
|
+
const formatted = pretty(chunk.toString())
|
|
228
|
+
t.assert.strictEqual(
|
|
229
|
+
formatted,
|
|
230
|
+
`[${formattedEpoch}] WARN (${pid}): foo\n`
|
|
231
|
+
)
|
|
232
|
+
cb()
|
|
233
|
+
}
|
|
234
|
+
}))
|
|
235
|
+
log.info({ msg: 'foo', 'log.level': 'warn' })
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
test('can use a customPrettifier on default level output', (t) => {
|
|
239
|
+
t.plan(1)
|
|
240
|
+
const veryCustomLevels = {
|
|
241
|
+
30: 'ok',
|
|
242
|
+
40: 'not great'
|
|
243
|
+
}
|
|
244
|
+
const customPrettifiers = {
|
|
245
|
+
level: (level) => `LEVEL: ${veryCustomLevels[level]}`
|
|
246
|
+
}
|
|
247
|
+
const pretty = prettyFactory({ customPrettifiers })
|
|
248
|
+
const log = pino({}, new Writable({
|
|
249
|
+
write (chunk, enc, cb) {
|
|
250
|
+
const formatted = pretty(chunk.toString())
|
|
251
|
+
t.assert.strictEqual(
|
|
252
|
+
formatted,
|
|
253
|
+
`[${formattedEpoch}] LEVEL: ok (${pid}): foo\n`
|
|
254
|
+
)
|
|
255
|
+
cb()
|
|
256
|
+
}
|
|
257
|
+
}))
|
|
258
|
+
log.info({ msg: 'foo' })
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
test('can use a customPrettifier on different-level-key output', (t) => {
|
|
262
|
+
t.plan(1)
|
|
263
|
+
const customPrettifiers = {
|
|
264
|
+
level: (level) => `LEVEL: ${level.toUpperCase()}`
|
|
265
|
+
}
|
|
266
|
+
const pretty = prettyFactory({ levelKey: 'bar', customPrettifiers })
|
|
267
|
+
const log = pino({}, new Writable({
|
|
268
|
+
write (chunk, enc, cb) {
|
|
269
|
+
const formatted = pretty(chunk.toString())
|
|
270
|
+
t.assert.strictEqual(
|
|
271
|
+
formatted,
|
|
272
|
+
`[${formattedEpoch}] LEVEL: WARN (${pid}): foo\n`
|
|
273
|
+
)
|
|
274
|
+
cb()
|
|
275
|
+
}
|
|
276
|
+
}))
|
|
277
|
+
log.info({ msg: 'foo', bar: 'warn' })
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
test('can use a customPrettifier to get final level label (no color)', (t) => {
|
|
281
|
+
t.plan(1)
|
|
282
|
+
const customPrettifiers = {
|
|
283
|
+
level: (level, key, logThis, { label }) => {
|
|
284
|
+
return `LEVEL: ${label}`
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const pretty = prettyFactory({ customPrettifiers, colorize: false, useOnlyCustomProps: false })
|
|
288
|
+
const log = pino({}, new Writable({
|
|
289
|
+
write (chunk, enc, cb) {
|
|
290
|
+
const formatted = pretty(chunk.toString())
|
|
291
|
+
t.assert.strictEqual(
|
|
292
|
+
formatted,
|
|
293
|
+
`[${formattedEpoch}] LEVEL: INFO (${pid}): foo\n`
|
|
294
|
+
)
|
|
295
|
+
cb()
|
|
296
|
+
}
|
|
297
|
+
}))
|
|
298
|
+
log.info({ msg: 'foo' })
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
test('can use a customPrettifier to get final level label (colorized)', (t) => {
|
|
302
|
+
t.plan(1)
|
|
303
|
+
const customPrettifiers = {
|
|
304
|
+
level: (level, key, logThis, { label, labelColorized }) => {
|
|
305
|
+
return `LEVEL: ${labelColorized}`
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const pretty = prettyFactory({ customPrettifiers, colorize: true, useOnlyCustomProps: false })
|
|
309
|
+
const log = pino({}, new Writable({
|
|
310
|
+
write (chunk, enc, cb) {
|
|
311
|
+
const formatted = pretty(chunk.toString())
|
|
312
|
+
t.assert.strictEqual(
|
|
313
|
+
formatted,
|
|
314
|
+
`[${formattedEpoch}] LEVEL: [32mINFO[39m (${pid}): [36mfoo[39m\n`
|
|
315
|
+
)
|
|
316
|
+
cb()
|
|
317
|
+
}
|
|
318
|
+
}))
|
|
319
|
+
log.info({ msg: 'foo' })
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
test('can use a customPrettifier on name output', (t) => {
|
|
323
|
+
t.plan(1)
|
|
324
|
+
const customPrettifiers = {
|
|
325
|
+
name: (hostname) => `NAME: ${hostname}`
|
|
326
|
+
}
|
|
327
|
+
const pretty = prettyFactory({ customPrettifiers })
|
|
328
|
+
const log = pino({}, new Writable({
|
|
329
|
+
write (chunk, enc, cb) {
|
|
330
|
+
const formatted = pretty(chunk.toString())
|
|
331
|
+
t.assert.strictEqual(
|
|
332
|
+
formatted,
|
|
333
|
+
`[${formattedEpoch}] INFO (NAME: logger/${pid}): foo\n`
|
|
334
|
+
)
|
|
335
|
+
cb()
|
|
336
|
+
}
|
|
337
|
+
}))
|
|
338
|
+
const child = log.child({ name: 'logger' })
|
|
339
|
+
child.info({ msg: 'foo' })
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
test('can use a customPrettifier on hostname and pid output', (t) => {
|
|
343
|
+
t.plan(1)
|
|
344
|
+
const customPrettifiers = {
|
|
345
|
+
hostname: (hostname) => `HOSTNAME: ${hostname}`,
|
|
346
|
+
pid: (pid) => `PID: ${pid}`
|
|
347
|
+
}
|
|
348
|
+
const pretty = prettyFactory({ customPrettifiers, ignore: '' })
|
|
349
|
+
const log = pino({}, new Writable({
|
|
350
|
+
write (chunk, enc, cb) {
|
|
351
|
+
const formatted = pretty(chunk.toString())
|
|
352
|
+
t.assert.strictEqual(
|
|
353
|
+
formatted,
|
|
354
|
+
`[${formattedEpoch}] INFO (PID: ${pid} on HOSTNAME: ${hostname}): foo\n`
|
|
355
|
+
)
|
|
356
|
+
cb()
|
|
357
|
+
}
|
|
358
|
+
}))
|
|
359
|
+
log.info({ msg: 'foo' })
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
test('can use a customPrettifier on default time output', (t) => {
|
|
363
|
+
t.plan(1)
|
|
364
|
+
const customPrettifiers = {
|
|
365
|
+
time: (timestamp) => `TIME: ${timestamp}`
|
|
366
|
+
}
|
|
367
|
+
const pretty = prettyFactory({ customPrettifiers })
|
|
368
|
+
const log = pino({}, new Writable({
|
|
369
|
+
write (chunk, enc, cb) {
|
|
370
|
+
const formatted = pretty(chunk.toString())
|
|
371
|
+
t.assert.strictEqual(
|
|
372
|
+
formatted,
|
|
373
|
+
`TIME: ${formattedEpoch} INFO (${pid}): foo\n`
|
|
374
|
+
)
|
|
375
|
+
cb()
|
|
376
|
+
}
|
|
377
|
+
}))
|
|
378
|
+
log.info('foo')
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
test('can use a customPrettifier on the caller', (t) => {
|
|
382
|
+
t.plan(1)
|
|
383
|
+
const customPrettifiers = {
|
|
384
|
+
caller: (caller) => `CALLER: ${caller}`
|
|
385
|
+
}
|
|
386
|
+
const pretty = prettyFactory({ customPrettifiers })
|
|
387
|
+
const log = pino({}, new Writable({
|
|
388
|
+
write (chunk, enc, cb) {
|
|
389
|
+
const formatted = pretty(chunk.toString())
|
|
390
|
+
t.assert.strictEqual(
|
|
391
|
+
formatted,
|
|
392
|
+
`[${formattedEpoch}] INFO (${pid}) <CALLER: test.js:10>: foo\n`
|
|
393
|
+
)
|
|
394
|
+
cb()
|
|
395
|
+
}
|
|
396
|
+
}))
|
|
397
|
+
log.info({ msg: 'foo', caller: 'test.js:10' })
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
test('can use a customPrettifier on translateTime-time output', (t) => {
|
|
401
|
+
t.plan(1)
|
|
402
|
+
const customPrettifiers = {
|
|
403
|
+
time: (timestamp) => `TIME: ${timestamp}`
|
|
404
|
+
}
|
|
405
|
+
const pretty = prettyFactory({ customPrettifiers, translateTime: true })
|
|
406
|
+
const log = pino({}, new Writable({
|
|
407
|
+
write (chunk, enc, cb) {
|
|
408
|
+
const formatted = pretty(chunk.toString())
|
|
409
|
+
t.assert.strictEqual(
|
|
410
|
+
formatted,
|
|
411
|
+
`TIME: ${formattedEpoch} INFO (${pid}): foo\n`
|
|
412
|
+
)
|
|
413
|
+
cb()
|
|
414
|
+
}
|
|
415
|
+
}))
|
|
416
|
+
log.info('foo')
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
test('will format time to UTC', (t) => {
|
|
420
|
+
t.plan(1)
|
|
421
|
+
const pretty = prettyFactory({ translateTime: true })
|
|
422
|
+
const log = pino({}, new Writable({
|
|
423
|
+
write (chunk, enc, cb) {
|
|
424
|
+
const formatted = pretty(chunk.toString())
|
|
425
|
+
t.assert.strictEqual(
|
|
426
|
+
formatted,
|
|
427
|
+
`[${formattedEpoch}] INFO (${pid}): foo\n`
|
|
428
|
+
)
|
|
429
|
+
cb()
|
|
430
|
+
}
|
|
431
|
+
}))
|
|
432
|
+
log.info('foo')
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
test('will format time to UTC in custom format', (t) => {
|
|
436
|
+
t.plan(1)
|
|
437
|
+
const pretty = prettyFactory({ translateTime: 'HH:MM:ss o' })
|
|
438
|
+
const log = pino({}, new Writable({
|
|
439
|
+
write (chunk, enc, cb) {
|
|
440
|
+
const formatted = pretty(chunk.toString())
|
|
441
|
+
const utcHour = dateformat(epoch, 'UTC:' + 'HH')
|
|
442
|
+
const offset = dateformat(epoch, 'UTC:' + 'o')
|
|
443
|
+
t.assert.strictEqual(
|
|
444
|
+
formatted,
|
|
445
|
+
`[${utcHour}:35:28 ${offset}] INFO (${pid}): foo\n`
|
|
446
|
+
)
|
|
447
|
+
cb()
|
|
448
|
+
}
|
|
449
|
+
}))
|
|
450
|
+
log.info('foo')
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
test('will format time to local systemzone in ISO 8601 format', (t) => {
|
|
454
|
+
t.plan(1)
|
|
455
|
+
const pretty = prettyFactory({ translateTime: 'sys:standard' })
|
|
456
|
+
const log = pino({}, new Writable({
|
|
457
|
+
write (chunk, enc, cb) {
|
|
458
|
+
const formatted = pretty(chunk.toString())
|
|
459
|
+
const localHour = dateformat(epoch, 'HH')
|
|
460
|
+
const localMinute = dateformat(epoch, 'MM')
|
|
461
|
+
const localDate = dateformat(epoch, 'yyyy-mm-dd')
|
|
462
|
+
const offset = dateformat(epoch, 'o')
|
|
463
|
+
t.assert.strictEqual(
|
|
464
|
+
formatted,
|
|
465
|
+
`[${localDate} ${localHour}:${localMinute}:28.992 ${offset}] INFO (${pid}): foo\n`
|
|
466
|
+
)
|
|
467
|
+
cb()
|
|
468
|
+
}
|
|
469
|
+
}))
|
|
470
|
+
log.info('foo')
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
test('will format time to local systemzone in custom format', (t) => {
|
|
474
|
+
t.plan(1)
|
|
475
|
+
const pretty = prettyFactory({
|
|
476
|
+
translateTime: 'SYS:yyyy/mm/dd HH:MM:ss o'
|
|
477
|
+
})
|
|
478
|
+
const log = pino({}, new Writable({
|
|
479
|
+
write (chunk, enc, cb) {
|
|
480
|
+
const formatted = pretty(chunk.toString())
|
|
481
|
+
const localHour = dateformat(epoch, 'HH')
|
|
482
|
+
const localMinute = dateformat(epoch, 'MM')
|
|
483
|
+
const localDate = dateformat(epoch, 'yyyy/mm/dd')
|
|
484
|
+
const offset = dateformat(epoch, 'o')
|
|
485
|
+
t.assert.strictEqual(
|
|
486
|
+
formatted,
|
|
487
|
+
`[${localDate} ${localHour}:${localMinute}:28 ${offset}] INFO (${pid}): foo\n`
|
|
488
|
+
)
|
|
489
|
+
cb()
|
|
490
|
+
}
|
|
491
|
+
}))
|
|
492
|
+
log.info('foo')
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
// TODO: 2019-03-30 -- We don't really want the indentation in this case? Or at least some better formatting.
|
|
496
|
+
test('handles missing time', (t) => {
|
|
497
|
+
t.plan(1)
|
|
498
|
+
const pretty = prettyFactory()
|
|
499
|
+
const formatted = pretty('{"hello":"world"}')
|
|
500
|
+
t.assert.strictEqual(formatted, ' hello: "world"\n')
|
|
501
|
+
})
|
|
502
|
+
|
|
503
|
+
test('handles missing pid, hostname and name', (t) => {
|
|
504
|
+
t.plan(1)
|
|
505
|
+
const pretty = prettyFactory()
|
|
506
|
+
const log = pino({ base: null }, new Writable({
|
|
507
|
+
write (chunk, enc, cb) {
|
|
508
|
+
const formatted = pretty(chunk.toString())
|
|
509
|
+
t.assert.match(formatted, /\[.*\] INFO: hello world/)
|
|
510
|
+
cb()
|
|
511
|
+
}
|
|
512
|
+
}))
|
|
513
|
+
log.info('hello world')
|
|
514
|
+
})
|
|
515
|
+
|
|
516
|
+
test('handles missing pid', (t) => {
|
|
517
|
+
t.plan(1)
|
|
518
|
+
const pretty = prettyFactory()
|
|
519
|
+
const name = 'test'
|
|
520
|
+
const msg = 'hello world'
|
|
521
|
+
const regex = new RegExp('\\[.*\\] INFO \\(' + name + '\\): ' + msg)
|
|
522
|
+
|
|
523
|
+
const opts = {
|
|
524
|
+
base: {
|
|
525
|
+
name,
|
|
526
|
+
hostname
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
const log = pino(opts, new Writable({
|
|
530
|
+
write (chunk, enc, cb) {
|
|
531
|
+
const formatted = pretty(chunk.toString())
|
|
532
|
+
t.assert.match(formatted, regex)
|
|
533
|
+
cb()
|
|
534
|
+
}
|
|
535
|
+
}))
|
|
536
|
+
|
|
537
|
+
log.info(msg)
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
test('handles missing hostname', (t) => {
|
|
541
|
+
t.plan(1)
|
|
542
|
+
const pretty = prettyFactory()
|
|
543
|
+
const name = 'test'
|
|
544
|
+
const msg = 'hello world'
|
|
545
|
+
const regex = new RegExp('\\[.*\\] INFO \\(' + name + '/' + pid + '\\): ' + msg)
|
|
546
|
+
|
|
547
|
+
const opts = {
|
|
548
|
+
base: {
|
|
549
|
+
name,
|
|
550
|
+
pid: process.pid
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
const log = pino(opts, new Writable({
|
|
554
|
+
write (chunk, enc, cb) {
|
|
555
|
+
const formatted = pretty(chunk.toString())
|
|
556
|
+
t.assert.match(formatted, regex)
|
|
557
|
+
cb()
|
|
558
|
+
}
|
|
559
|
+
}))
|
|
560
|
+
|
|
561
|
+
log.info(msg)
|
|
562
|
+
})
|
|
563
|
+
|
|
564
|
+
test('handles missing name', (t) => {
|
|
565
|
+
t.plan(1)
|
|
566
|
+
const pretty = prettyFactory()
|
|
567
|
+
const msg = 'hello world'
|
|
568
|
+
const regex = new RegExp('\\[.*\\] INFO \\(' + process.pid + '\\): ' + msg)
|
|
569
|
+
|
|
570
|
+
const opts = {
|
|
571
|
+
base: {
|
|
572
|
+
hostname,
|
|
573
|
+
pid: process.pid
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
const log = pino(opts, new Writable({
|
|
577
|
+
write (chunk, enc, cb) {
|
|
578
|
+
const formatted = pretty(chunk.toString())
|
|
579
|
+
t.assert.match(formatted, regex)
|
|
580
|
+
cb()
|
|
581
|
+
}
|
|
582
|
+
}))
|
|
583
|
+
|
|
584
|
+
log.info(msg)
|
|
585
|
+
})
|
|
586
|
+
|
|
587
|
+
test('works without time', (t) => {
|
|
588
|
+
t.plan(1)
|
|
589
|
+
const pretty = prettyFactory()
|
|
590
|
+
const log = pino({ timestamp: null }, new Writable({
|
|
591
|
+
write (chunk, enc, cb) {
|
|
592
|
+
const formatted = pretty(chunk.toString())
|
|
593
|
+
t.assert.strictEqual(formatted, `INFO (${pid}): hello world\n`)
|
|
594
|
+
cb()
|
|
595
|
+
}
|
|
596
|
+
}))
|
|
597
|
+
log.info('hello world')
|
|
598
|
+
})
|
|
599
|
+
|
|
600
|
+
test('prettifies properties', (t) => {
|
|
601
|
+
t.plan(1)
|
|
602
|
+
const pretty = prettyFactory()
|
|
603
|
+
const log = pino({}, new Writable({
|
|
604
|
+
write (chunk, enc, cb) {
|
|
605
|
+
const formatted = pretty(chunk.toString())
|
|
606
|
+
match(formatted, ' a: "b"', t)
|
|
607
|
+
cb()
|
|
608
|
+
}
|
|
609
|
+
}))
|
|
610
|
+
log.info({ a: 'b' }, 'hello world')
|
|
611
|
+
})
|
|
612
|
+
|
|
613
|
+
test('prettifies nested properties', (t) => {
|
|
614
|
+
t.plan(6)
|
|
615
|
+
const expectedLines = [
|
|
616
|
+
' a: {',
|
|
617
|
+
' "b": {',
|
|
618
|
+
' "c": "d"',
|
|
619
|
+
' }',
|
|
620
|
+
' }'
|
|
621
|
+
]
|
|
622
|
+
const pretty = prettyFactory()
|
|
623
|
+
const log = pino({}, new Writable({
|
|
624
|
+
write (chunk, enc, cb) {
|
|
625
|
+
const formatted = pretty(chunk.toString())
|
|
626
|
+
const lines = formatted.split('\n')
|
|
627
|
+
t.assert.strictEqual(lines.length, expectedLines.length + 2)
|
|
628
|
+
lines.shift(); lines.pop()
|
|
629
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
630
|
+
t.assert.strictEqual(lines[i], expectedLines[i])
|
|
631
|
+
}
|
|
632
|
+
cb()
|
|
633
|
+
}
|
|
634
|
+
}))
|
|
635
|
+
log.info({ a: { b: { c: 'd' } } }, 'hello world')
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
test('treats the name with care', (t) => {
|
|
639
|
+
t.plan(1)
|
|
640
|
+
const pretty = prettyFactory()
|
|
641
|
+
const log = pino({ name: 'matteo' }, new Writable({
|
|
642
|
+
write (chunk, enc, cb) {
|
|
643
|
+
const formatted = pretty(chunk.toString())
|
|
644
|
+
t.assert.strictEqual(formatted, `[${formattedEpoch}] INFO (matteo/${pid}): hello world\n`)
|
|
645
|
+
cb()
|
|
646
|
+
}
|
|
647
|
+
}))
|
|
648
|
+
log.info('hello world')
|
|
649
|
+
})
|
|
650
|
+
|
|
651
|
+
test('handles spec allowed primitives', (t) => {
|
|
652
|
+
const pretty = prettyFactory()
|
|
653
|
+
let formatted = pretty(null)
|
|
654
|
+
t.assert.strictEqual(formatted, 'null\n')
|
|
655
|
+
|
|
656
|
+
formatted = pretty(true)
|
|
657
|
+
t.assert.strictEqual(formatted, 'true\n')
|
|
658
|
+
|
|
659
|
+
formatted = pretty(false)
|
|
660
|
+
t.assert.strictEqual(formatted, 'false\n')
|
|
661
|
+
})
|
|
662
|
+
|
|
663
|
+
test('handles numbers', (t) => {
|
|
664
|
+
const pretty = prettyFactory()
|
|
665
|
+
let formatted = pretty(2)
|
|
666
|
+
t.assert.strictEqual(formatted, '2\n')
|
|
667
|
+
|
|
668
|
+
formatted = pretty(-2)
|
|
669
|
+
t.assert.strictEqual(formatted, '-2\n')
|
|
670
|
+
|
|
671
|
+
formatted = pretty(0.2)
|
|
672
|
+
t.assert.strictEqual(formatted, '0.2\n')
|
|
673
|
+
|
|
674
|
+
formatted = pretty(Infinity)
|
|
675
|
+
t.assert.strictEqual(formatted, 'Infinity\n')
|
|
676
|
+
|
|
677
|
+
formatted = pretty(NaN)
|
|
678
|
+
t.assert.strictEqual(formatted, 'NaN\n')
|
|
679
|
+
})
|
|
680
|
+
|
|
681
|
+
test('handles `undefined` input', (t) => {
|
|
682
|
+
t.plan(1)
|
|
683
|
+
const pretty = prettyFactory()
|
|
684
|
+
const formatted = pretty(undefined)
|
|
685
|
+
t.assert.strictEqual(formatted, 'undefined\n')
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
test('handles customLogLevel', (t) => {
|
|
689
|
+
t.plan(1)
|
|
690
|
+
const pretty = prettyFactory()
|
|
691
|
+
const log = pino({ customLevels: { testCustom: 35 } }, new Writable({
|
|
692
|
+
write (chunk, enc, cb) {
|
|
693
|
+
const formatted = pretty(chunk.toString())
|
|
694
|
+
t.assert.match(formatted, /USERLVL/)
|
|
695
|
+
cb()
|
|
696
|
+
}
|
|
697
|
+
}))
|
|
698
|
+
log.testCustom('test message')
|
|
699
|
+
})
|
|
700
|
+
|
|
701
|
+
test('filter some lines based on minimumLevel', (t) => {
|
|
702
|
+
t.plan(3)
|
|
703
|
+
const pretty = prettyFactory({ minimumLevel: 'info' })
|
|
704
|
+
const expected = [
|
|
705
|
+
undefined,
|
|
706
|
+
undefined,
|
|
707
|
+
`[${formattedEpoch}] INFO (${pid}): baz\n`
|
|
708
|
+
]
|
|
709
|
+
const log = pino({}, new Writable({
|
|
710
|
+
write (chunk, enc, cb) {
|
|
711
|
+
const formatted = pretty(chunk.toString())
|
|
712
|
+
t.assert.strictEqual(
|
|
713
|
+
formatted,
|
|
714
|
+
expected.shift()
|
|
715
|
+
)
|
|
716
|
+
cb()
|
|
717
|
+
}
|
|
718
|
+
}))
|
|
719
|
+
log.info({ msg: 'foo', level: 10 })
|
|
720
|
+
log.info({ msg: 'bar', level: 20 })
|
|
721
|
+
// only this line will be formatted
|
|
722
|
+
log.info({ msg: 'baz', level: 30 })
|
|
723
|
+
})
|
|
724
|
+
|
|
725
|
+
test('filter lines based on minimumLevel using custom levels and level key', (t) => {
|
|
726
|
+
t.plan(3)
|
|
727
|
+
const pretty = prettyFactory({ minimumLevel: 20, levelKey: 'bar' })
|
|
728
|
+
const expected = [
|
|
729
|
+
undefined,
|
|
730
|
+
`[${formattedEpoch}] DEBUG (${pid}): bar\n`,
|
|
731
|
+
`[${formattedEpoch}] INFO (${pid}): baz\n`
|
|
732
|
+
]
|
|
733
|
+
const log = pino({}, new Writable({
|
|
734
|
+
write (chunk, enc, cb) {
|
|
735
|
+
const formatted = pretty(chunk.toString())
|
|
736
|
+
t.assert.strictEqual(
|
|
737
|
+
formatted,
|
|
738
|
+
expected.shift()
|
|
739
|
+
)
|
|
740
|
+
cb()
|
|
741
|
+
}
|
|
742
|
+
}))
|
|
743
|
+
log.info({ msg: 'foo', bar: 10 })
|
|
744
|
+
log.info({ msg: 'bar', bar: 20 })
|
|
745
|
+
log.info({ msg: 'baz', bar: 30 })
|
|
746
|
+
})
|
|
747
|
+
|
|
748
|
+
test('formats a line with an undefined field', (t) => {
|
|
749
|
+
t.plan(1)
|
|
750
|
+
const pretty = prettyFactory()
|
|
751
|
+
const log = pino({}, new Writable({
|
|
752
|
+
write (chunk, enc, cb) {
|
|
753
|
+
const obj = JSON.parse(chunk.toString())
|
|
754
|
+
// weird hack, but we should not crash
|
|
755
|
+
obj.a = undefined
|
|
756
|
+
const formatted = pretty(obj)
|
|
757
|
+
t.assert.strictEqual(
|
|
758
|
+
formatted,
|
|
759
|
+
`[${formattedEpoch}] INFO (${pid}): foo\n`
|
|
760
|
+
)
|
|
761
|
+
cb()
|
|
762
|
+
}
|
|
763
|
+
}))
|
|
764
|
+
log.info('foo')
|
|
765
|
+
})
|
|
766
|
+
|
|
767
|
+
test('prettifies msg object', (t) => {
|
|
768
|
+
t.plan(6)
|
|
769
|
+
const expectedLines = [
|
|
770
|
+
' msg: {',
|
|
771
|
+
' "b": {',
|
|
772
|
+
' "c": "d"',
|
|
773
|
+
' }',
|
|
774
|
+
' }'
|
|
775
|
+
]
|
|
776
|
+
const pretty = prettyFactory()
|
|
777
|
+
const log = pino({}, new Writable({
|
|
778
|
+
write (chunk, enc, cb) {
|
|
779
|
+
const formatted = pretty(chunk.toString())
|
|
780
|
+
const lines = formatted.split('\n')
|
|
781
|
+
t.assert.strictEqual(lines.length, expectedLines.length + 2)
|
|
782
|
+
lines.shift(); lines.pop()
|
|
783
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
784
|
+
t.assert.strictEqual(lines[i], expectedLines[i])
|
|
785
|
+
}
|
|
786
|
+
cb()
|
|
787
|
+
}
|
|
788
|
+
}))
|
|
789
|
+
log.info({ msg: { b: { c: 'd' } } })
|
|
790
|
+
})
|
|
791
|
+
|
|
792
|
+
test('prettifies msg object with circular references', (t) => {
|
|
793
|
+
t.plan(7)
|
|
794
|
+
const expectedLines = [
|
|
795
|
+
' msg: {',
|
|
796
|
+
' "a": "[Circular]",',
|
|
797
|
+
' "b": {',
|
|
798
|
+
' "c": "d"',
|
|
799
|
+
' }',
|
|
800
|
+
' }'
|
|
801
|
+
]
|
|
802
|
+
const pretty = prettyFactory()
|
|
803
|
+
const log = pino({}, new Writable({
|
|
804
|
+
write (chunk, enc, cb) {
|
|
805
|
+
const formatted = pretty(chunk.toString())
|
|
806
|
+
const lines = formatted.split('\n')
|
|
807
|
+
t.assert.strictEqual(lines.length, expectedLines.length + 2)
|
|
808
|
+
lines.shift(); lines.pop()
|
|
809
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
810
|
+
t.assert.strictEqual(lines[i], expectedLines[i])
|
|
811
|
+
}
|
|
812
|
+
cb()
|
|
813
|
+
}
|
|
814
|
+
}))
|
|
815
|
+
|
|
816
|
+
const msg = { b: { c: 'd' } }
|
|
817
|
+
msg.a = msg
|
|
818
|
+
log.info({ msg })
|
|
819
|
+
})
|
|
820
|
+
|
|
821
|
+
test('prettifies custom key', (t) => {
|
|
822
|
+
t.plan(1)
|
|
823
|
+
const pretty = prettyFactory({
|
|
824
|
+
customPrettifiers: {
|
|
825
|
+
foo: val => `${val}_baz\nmultiline`,
|
|
826
|
+
cow: val => val.toUpperCase()
|
|
827
|
+
}
|
|
828
|
+
})
|
|
829
|
+
const arst = pretty('{"msg":"hello world", "foo": "bar", "cow": "moo", "level":30}')
|
|
830
|
+
t.assert.strictEqual(arst, 'INFO: hello world\n foo: bar_baz\n multiline\n cow: MOO\n')
|
|
831
|
+
})
|
|
832
|
+
|
|
833
|
+
test('does not add trailing space if prettified value begins with eol', (t) => {
|
|
834
|
+
t.plan(1)
|
|
835
|
+
const pretty = prettyFactory({
|
|
836
|
+
customPrettifiers: {
|
|
837
|
+
calls: val => '\n' + val.map(it => ' ' + it).join('\n')
|
|
838
|
+
}
|
|
839
|
+
})
|
|
840
|
+
const arst = pretty('{"msg":"doing work","calls":["step 1","step 2","step 3"],"level":30}')
|
|
841
|
+
t.assert.strictEqual(arst, 'INFO: doing work\n calls:\n step 1\n step 2\n step 3\n')
|
|
842
|
+
})
|
|
843
|
+
|
|
844
|
+
test('does not prettify custom key that does not exists', (t) => {
|
|
845
|
+
t.plan(1)
|
|
846
|
+
const pretty = prettyFactory({
|
|
847
|
+
customPrettifiers: {
|
|
848
|
+
foo: val => `${val}_baz`,
|
|
849
|
+
cow: val => val.toUpperCase()
|
|
850
|
+
}
|
|
851
|
+
})
|
|
852
|
+
const arst = pretty('{"msg":"hello world", "foo": "bar", "level":30}')
|
|
853
|
+
t.assert.strictEqual(arst, 'INFO: hello world\n foo: bar_baz\n')
|
|
854
|
+
})
|
|
855
|
+
|
|
856
|
+
test('prettifies object with some undefined values', (t) => {
|
|
857
|
+
t.plan(1)
|
|
858
|
+
const destination = new Writable({
|
|
859
|
+
write (chunk, _, cb) {
|
|
860
|
+
t.assert.strictEqual(
|
|
861
|
+
chunk + '',
|
|
862
|
+
`[${formattedEpoch}] INFO (${pid}):\n a: {\n "b": "c"\n }\n n: null\n`
|
|
863
|
+
)
|
|
864
|
+
cb()
|
|
865
|
+
}
|
|
866
|
+
})
|
|
867
|
+
const pretty = pinoPretty({
|
|
868
|
+
destination,
|
|
869
|
+
colorize: false
|
|
870
|
+
})
|
|
871
|
+
const log = pino({}, pretty)
|
|
872
|
+
log.info({
|
|
873
|
+
a: { b: 'c' },
|
|
874
|
+
s: Symbol.for('s'),
|
|
875
|
+
f: f => f,
|
|
876
|
+
c: class C {},
|
|
877
|
+
n: null,
|
|
878
|
+
err: { toJSON () {} }
|
|
879
|
+
})
|
|
880
|
+
})
|
|
881
|
+
|
|
882
|
+
test('ignores multiple keys', (t) => {
|
|
883
|
+
t.plan(1)
|
|
884
|
+
const pretty = prettyFactory({ ignore: 'pid,hostname' })
|
|
885
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
886
|
+
t.assert.strictEqual(arst, `[${formattedEpoch}] INFO: hello world\n`)
|
|
887
|
+
})
|
|
888
|
+
|
|
889
|
+
test('ignores a single key', (t) => {
|
|
890
|
+
t.plan(1)
|
|
891
|
+
const pretty = prettyFactory({ ignore: 'pid' })
|
|
892
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
893
|
+
t.assert.strictEqual(arst, `[${formattedEpoch}] INFO (on ${hostname}): hello world\n`)
|
|
894
|
+
})
|
|
895
|
+
|
|
896
|
+
test('ignores time', (t) => {
|
|
897
|
+
t.plan(1)
|
|
898
|
+
const pretty = prettyFactory({ ignore: 'time' })
|
|
899
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
900
|
+
t.assert.strictEqual(arst, `INFO (${pid} on ${hostname}): hello world\n`)
|
|
901
|
+
})
|
|
902
|
+
|
|
903
|
+
test('ignores time and level', (t) => {
|
|
904
|
+
t.plan(1)
|
|
905
|
+
const pretty = prettyFactory({ ignore: 'time,level' })
|
|
906
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
907
|
+
t.assert.strictEqual(arst, `(${pid} on ${hostname}): hello world\n`)
|
|
908
|
+
})
|
|
909
|
+
|
|
910
|
+
test('ignores all keys but message', (t) => {
|
|
911
|
+
t.plan(1)
|
|
912
|
+
const pretty = prettyFactory({ ignore: 'time,level,name,pid,hostname' })
|
|
913
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
914
|
+
t.assert.strictEqual(arst, 'hello world\n')
|
|
915
|
+
})
|
|
916
|
+
|
|
917
|
+
test('include nothing', (t) => {
|
|
918
|
+
t.plan(1)
|
|
919
|
+
const pretty = prettyFactory({ include: '' })
|
|
920
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
921
|
+
t.assert.strictEqual(arst, 'hello world\n')
|
|
922
|
+
})
|
|
923
|
+
|
|
924
|
+
test('include multiple keys', (t) => {
|
|
925
|
+
t.plan(1)
|
|
926
|
+
const pretty = prettyFactory({ include: 'time,level' })
|
|
927
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
928
|
+
t.assert.strictEqual(arst, `[${formattedEpoch}] INFO: hello world\n`)
|
|
929
|
+
})
|
|
930
|
+
|
|
931
|
+
test('include a single key', (t) => {
|
|
932
|
+
t.plan(1)
|
|
933
|
+
const pretty = prettyFactory({ include: 'level' })
|
|
934
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
935
|
+
t.assert.strictEqual(arst, 'INFO: hello world\n')
|
|
936
|
+
})
|
|
937
|
+
|
|
938
|
+
test('log error-like object', (t) => {
|
|
939
|
+
t.plan(7)
|
|
940
|
+
const expectedLines = [
|
|
941
|
+
' type: "Error"',
|
|
942
|
+
' message: "m"',
|
|
943
|
+
' stack: [',
|
|
944
|
+
' "line1",',
|
|
945
|
+
' "line2"',
|
|
946
|
+
' ]'
|
|
947
|
+
]
|
|
948
|
+
const pretty = prettyFactory()
|
|
949
|
+
const log = pino({}, new Writable({
|
|
950
|
+
write (chunk, enc, cb) {
|
|
951
|
+
const formatted = pretty(chunk.toString())
|
|
952
|
+
const lines = formatted.split('\n')
|
|
953
|
+
t.assert.strictEqual(lines.length, expectedLines.length + 2)
|
|
954
|
+
lines.shift(); lines.pop()
|
|
955
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
956
|
+
t.assert.strictEqual(lines[i], expectedLines[i])
|
|
957
|
+
}
|
|
958
|
+
cb()
|
|
959
|
+
}
|
|
960
|
+
}))
|
|
961
|
+
log.error({ type: 'Error', message: 'm', stack: ['line1', 'line2'] })
|
|
962
|
+
})
|
|
963
|
+
|
|
964
|
+
test('include should override ignore', (t) => {
|
|
965
|
+
t.plan(1)
|
|
966
|
+
const pretty = prettyFactory({ ignore: 'time,level', include: 'time,level' })
|
|
967
|
+
const arst = pretty(`{"msg":"hello world", "pid":"${pid}", "hostname":"${hostname}", "time":${epoch}, "level":30}`)
|
|
968
|
+
t.assert.strictEqual(arst, `[${formattedEpoch}] INFO: hello world\n`)
|
|
969
|
+
})
|
|
970
|
+
|
|
971
|
+
test('include a single key with null object', (t) => {
|
|
972
|
+
t.plan(1)
|
|
973
|
+
const pretty = prettyFactory({ include: 'level' })
|
|
974
|
+
const obj = new Empty()
|
|
975
|
+
obj.nested = 'property'
|
|
976
|
+
const arst = pretty({
|
|
977
|
+
msg: 'hello world',
|
|
978
|
+
pid: `${pid}`,
|
|
979
|
+
hostname,
|
|
980
|
+
time: epoch,
|
|
981
|
+
obj,
|
|
982
|
+
level: 30
|
|
983
|
+
})
|
|
984
|
+
t.assert.strictEqual(arst, 'INFO: hello world\n')
|
|
985
|
+
})
|
|
986
|
+
|
|
987
|
+
test('prettifies trace caller', (t) => {
|
|
988
|
+
t.plan(1)
|
|
989
|
+
const traceCaller = (instance) => {
|
|
990
|
+
const { symbols: { asJsonSym } } = pino
|
|
991
|
+
const get = (target, name) => name === asJsonSym ? asJson : target[name]
|
|
992
|
+
|
|
993
|
+
function asJson (...args) {
|
|
994
|
+
args[0] = args[0] || {}
|
|
995
|
+
args[0].caller = '/tmp/script.js'
|
|
996
|
+
return instance[asJsonSym].apply(this, args)
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
return new Proxy(instance, { get })
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
const pretty = prettyFactory()
|
|
1003
|
+
const log = traceCaller(pino({}, new Writable({
|
|
1004
|
+
write (chunk, enc, cb) {
|
|
1005
|
+
const formatted = pretty(chunk.toString())
|
|
1006
|
+
t.assert.strictEqual(
|
|
1007
|
+
formatted,
|
|
1008
|
+
`[${formattedEpoch}] INFO (${pid}) </tmp/script.js>: foo\n`
|
|
1009
|
+
)
|
|
1010
|
+
cb()
|
|
1011
|
+
}
|
|
1012
|
+
})))
|
|
1013
|
+
log.info('foo')
|
|
1014
|
+
})
|
|
1015
|
+
|
|
1016
|
+
test('handles specified timestampKey', (t) => {
|
|
1017
|
+
t.plan(1)
|
|
1018
|
+
const pretty = prettyFactory({ timestampKey: '@timestamp' })
|
|
1019
|
+
const arst = pretty(`{"msg":"hello world", "@timestamp":${epoch}, "level":30}`)
|
|
1020
|
+
t.assert.strictEqual(arst, `[${formattedEpoch}] INFO: hello world\n`)
|
|
1021
|
+
})
|
|
1022
|
+
|
|
1023
|
+
test('keeps "v" key in log', (t) => {
|
|
1024
|
+
t.plan(1)
|
|
1025
|
+
const pretty = prettyFactory({ ignore: 'time' })
|
|
1026
|
+
const log = pino({}, new Writable({
|
|
1027
|
+
write (chunk, enc, cb) {
|
|
1028
|
+
const formatted = pretty(chunk.toString())
|
|
1029
|
+
t.assert.strictEqual(formatted, `INFO (${pid} on ${hostname}):\n v: 1\n`)
|
|
1030
|
+
cb()
|
|
1031
|
+
}
|
|
1032
|
+
}))
|
|
1033
|
+
log.info({ v: 1 })
|
|
1034
|
+
})
|
|
1035
|
+
|
|
1036
|
+
test('Hide object `{ key: "value" }` from output when flag `hideObject` is set', (t) => {
|
|
1037
|
+
t.plan(1)
|
|
1038
|
+
const pretty = prettyFactory({ hideObject: true })
|
|
1039
|
+
const log = pino({}, new Writable({
|
|
1040
|
+
write (chunk, enc, cb) {
|
|
1041
|
+
const formatted = pretty(chunk.toString())
|
|
1042
|
+
t.assert.strictEqual(formatted, `[${formattedEpoch}] INFO (${pid}): hello world\n`)
|
|
1043
|
+
cb()
|
|
1044
|
+
}
|
|
1045
|
+
}))
|
|
1046
|
+
log.info({ key: 'value' }, 'hello world')
|
|
1047
|
+
})
|
|
1048
|
+
|
|
1049
|
+
test('Prints extra objects on one line with singleLine=true', (t) => {
|
|
1050
|
+
t.plan(1)
|
|
1051
|
+
const pretty = prettyFactory({
|
|
1052
|
+
singleLine: true,
|
|
1053
|
+
colorize: false,
|
|
1054
|
+
customPrettifiers: {
|
|
1055
|
+
upper: val => val.toUpperCase(),
|
|
1056
|
+
undef: () => undefined
|
|
1057
|
+
}
|
|
1058
|
+
})
|
|
1059
|
+
const log = pino({}, new Writable({
|
|
1060
|
+
write (chunk, enc, cb) {
|
|
1061
|
+
const formatted = pretty(chunk.toString())
|
|
1062
|
+
t.assert.strictEqual(formatted, `[${formattedEpoch}] INFO (${pid}): message {"extra":{"foo":"bar","number":42},"upper":"FOOBAR"}\n`)
|
|
1063
|
+
|
|
1064
|
+
cb()
|
|
1065
|
+
}
|
|
1066
|
+
}))
|
|
1067
|
+
log.info({ msg: 'message', extra: { foo: 'bar', number: 42 }, upper: 'foobar', undef: 'this will not show up' })
|
|
1068
|
+
})
|
|
1069
|
+
|
|
1070
|
+
test('Does not print empty object with singleLine=true', (t) => {
|
|
1071
|
+
t.plan(1)
|
|
1072
|
+
const pretty = prettyFactory({ singleLine: true, colorize: false })
|
|
1073
|
+
const log = pino({}, new Writable({
|
|
1074
|
+
write (chunk, enc, cb) {
|
|
1075
|
+
const formatted = pretty(chunk.toString())
|
|
1076
|
+
t.assert.strictEqual(formatted, `[${formattedEpoch}] INFO (${pid}): message\n`)
|
|
1077
|
+
cb()
|
|
1078
|
+
}
|
|
1079
|
+
}))
|
|
1080
|
+
log.info({ msg: 'message' })
|
|
1081
|
+
})
|
|
1082
|
+
|
|
1083
|
+
test('default options', (t) => {
|
|
1084
|
+
t.plan(1)
|
|
1085
|
+
t.assert.doesNotThrow(pinoPretty)
|
|
1086
|
+
})
|
|
1087
|
+
|
|
1088
|
+
test('does not call fs.close on stdout stream', (t) => {
|
|
1089
|
+
t.plan(2)
|
|
1090
|
+
const destination = pino.destination({ minLength: 4096, sync: true })
|
|
1091
|
+
const prettyDestination = pinoPretty({ destination, colorize: false })
|
|
1092
|
+
const log = pino(prettyDestination)
|
|
1093
|
+
log.info('this message has been buffered')
|
|
1094
|
+
const chunks = []
|
|
1095
|
+
const { close, writeSync } = fs
|
|
1096
|
+
let closeCalled = false
|
|
1097
|
+
fs.close = new Proxy(close, {
|
|
1098
|
+
apply: (target, self, args) => {
|
|
1099
|
+
closeCalled = true
|
|
1100
|
+
}
|
|
1101
|
+
})
|
|
1102
|
+
fs.writeSync = new Proxy(writeSync, {
|
|
1103
|
+
apply: (target, self, args) => {
|
|
1104
|
+
chunks.push(args[1])
|
|
1105
|
+
return args[1].length
|
|
1106
|
+
}
|
|
1107
|
+
})
|
|
1108
|
+
destination.end()
|
|
1109
|
+
Object.assign(fs, { close, writeSync })
|
|
1110
|
+
t.assert.match(chunks.join(''), /INFO .+: this message has been buffered/)
|
|
1111
|
+
t.assert.strictEqual(closeCalled, false)
|
|
1112
|
+
})
|
|
1113
|
+
|
|
1114
|
+
test('wait for close event from destination', (t, end) => {
|
|
1115
|
+
t.plan(2)
|
|
1116
|
+
const destination = pino.destination({ minLength: 4096, sync: true })
|
|
1117
|
+
const prettyDestination = pinoPretty({ destination, colorize: false })
|
|
1118
|
+
const log = pino(prettyDestination)
|
|
1119
|
+
log.info('this message has been buffered')
|
|
1120
|
+
const chunks = []
|
|
1121
|
+
const { close, writeSync } = fs
|
|
1122
|
+
fs.close = new Proxy(close, {
|
|
1123
|
+
apply: (target, self, args) => {
|
|
1124
|
+
}
|
|
1125
|
+
})
|
|
1126
|
+
fs.writeSync = new Proxy(writeSync, {
|
|
1127
|
+
apply: (target, self, args) => {
|
|
1128
|
+
chunks.push(args[1])
|
|
1129
|
+
return args[1].length
|
|
1130
|
+
}
|
|
1131
|
+
})
|
|
1132
|
+
t.after(() => {
|
|
1133
|
+
Object.assign(fs, { close, writeSync })
|
|
1134
|
+
})
|
|
1135
|
+
let destinationClosed = false
|
|
1136
|
+
destination.on('close', () => {
|
|
1137
|
+
destinationClosed = true
|
|
1138
|
+
})
|
|
1139
|
+
prettyDestination.on('close', () => {
|
|
1140
|
+
t.assert.match(chunks.join(''), /INFO .+: this message has been buffered/)
|
|
1141
|
+
t.assert.strictEqual(destinationClosed, true)
|
|
1142
|
+
end()
|
|
1143
|
+
})
|
|
1144
|
+
prettyDestination.end()
|
|
1145
|
+
})
|
|
1146
|
+
|
|
1147
|
+
test('stream usage', async (t) => {
|
|
1148
|
+
t.plan(1)
|
|
1149
|
+
const tmpDir = join(__dirname, '.tmp_' + Date.now())
|
|
1150
|
+
t.after(() => rimraf.sync(tmpDir))
|
|
1151
|
+
|
|
1152
|
+
const destination = join(tmpDir, 'output')
|
|
1153
|
+
|
|
1154
|
+
const pretty = pinoPretty({
|
|
1155
|
+
singleLine: true,
|
|
1156
|
+
colorize: false,
|
|
1157
|
+
mkdir: true,
|
|
1158
|
+
append: false,
|
|
1159
|
+
destination: new SonicBoom({ dest: destination, async: false, mkdir: true, append: true }),
|
|
1160
|
+
customPrettifiers: {
|
|
1161
|
+
upper: val => val.toUpperCase(),
|
|
1162
|
+
undef: () => undefined
|
|
1163
|
+
}
|
|
1164
|
+
})
|
|
1165
|
+
const log = pino(pretty)
|
|
1166
|
+
log.info({ msg: 'message', extra: { foo: 'bar', number: 42 }, upper: 'foobar', undef: 'this will not show up' })
|
|
1167
|
+
|
|
1168
|
+
await watchFileCreated(destination)
|
|
1169
|
+
|
|
1170
|
+
const formatted = fs.readFileSync(destination, 'utf8')
|
|
1171
|
+
|
|
1172
|
+
t.assert.strictEqual(formatted, `[${formattedEpoch}] INFO (${pid}): message {"extra":{"foo":"bar","number":42},"upper":"FOOBAR"}\n`)
|
|
1173
|
+
})
|
|
1174
|
+
|
|
1175
|
+
test('sync option', async (t) => {
|
|
1176
|
+
t.plan(1)
|
|
1177
|
+
const tmpDir = join(__dirname, '.tmp_' + Date.now())
|
|
1178
|
+
t.after(() => rimraf.sync(tmpDir))
|
|
1179
|
+
|
|
1180
|
+
const destination = join(tmpDir, 'output')
|
|
1181
|
+
|
|
1182
|
+
const log = pino(pino.transport({
|
|
1183
|
+
target: '..',
|
|
1184
|
+
options: {
|
|
1185
|
+
singleLine: true,
|
|
1186
|
+
colorize: false,
|
|
1187
|
+
mkdir: true,
|
|
1188
|
+
append: false,
|
|
1189
|
+
sync: true,
|
|
1190
|
+
destination
|
|
1191
|
+
}
|
|
1192
|
+
}))
|
|
1193
|
+
log.info({ msg: 'message', extra: { foo: 'bar', number: 43 }, upper: 'foobar' })
|
|
1194
|
+
|
|
1195
|
+
await watchFileCreated(destination)
|
|
1196
|
+
|
|
1197
|
+
const formatted = fs.readFileSync(destination, 'utf8')
|
|
1198
|
+
|
|
1199
|
+
t.assert.strictEqual(formatted, `[${formattedEpoch}] INFO (${pid}): message {"extra":{"foo":"bar","number":43},"upper":"foobar"}\n`)
|
|
1200
|
+
})
|
|
1201
|
+
|
|
1202
|
+
test('support custom colors object', async (t) => {
|
|
1203
|
+
t.plan(1)
|
|
1204
|
+
const pretty = prettyFactory({
|
|
1205
|
+
colorize: true,
|
|
1206
|
+
customColors: {
|
|
1207
|
+
trace: 'cyan',
|
|
1208
|
+
debug: 'blue',
|
|
1209
|
+
info: 'green',
|
|
1210
|
+
warn: 'yellow',
|
|
1211
|
+
error: 'red',
|
|
1212
|
+
fatal: 'red'
|
|
1213
|
+
}
|
|
1214
|
+
})
|
|
1215
|
+
const log = pino({}, new Writable({
|
|
1216
|
+
write (chunk, enc, cb) {
|
|
1217
|
+
const formatted = pretty(chunk.toString())
|
|
1218
|
+
t.assert.strictEqual(
|
|
1219
|
+
formatted,
|
|
1220
|
+
`[${formattedEpoch}] \u001B[32mINFO\u001B[39m (${pid}): \u001B[36mfoo\u001B[39m\n`
|
|
1221
|
+
)
|
|
1222
|
+
cb()
|
|
1223
|
+
}
|
|
1224
|
+
}))
|
|
1225
|
+
log.info('foo')
|
|
1226
|
+
})
|
|
1227
|
+
|
|
1228
|
+
test('check support for colors', (t) => {
|
|
1229
|
+
t.plan(1)
|
|
1230
|
+
const isColorSupported = pinoPretty.isColorSupported
|
|
1231
|
+
t.assert.strictEqual(typeof isColorSupported, 'boolean')
|
|
1232
|
+
})
|
|
1233
|
+
})
|
|
1234
|
+
|
|
1235
|
+
if (semver.gte(pino.version, '8.21.0')) {
|
|
1236
|
+
describe('using pino config', () => {
|
|
1237
|
+
beforeEach(() => {
|
|
1238
|
+
Date.originalNow = Date.now
|
|
1239
|
+
Date.now = () => epoch
|
|
1240
|
+
})
|
|
1241
|
+
afterEach(() => {
|
|
1242
|
+
Date.now = Date.originalNow
|
|
1243
|
+
delete Date.originalNow
|
|
1244
|
+
})
|
|
1245
|
+
|
|
1246
|
+
test('can use different message keys', (t) => {
|
|
1247
|
+
t.plan(1)
|
|
1248
|
+
const destination = new Writable({
|
|
1249
|
+
write (formatted, enc, cb) {
|
|
1250
|
+
t.assert.strictEqual(
|
|
1251
|
+
formatted.toString(),
|
|
1252
|
+
`[${formattedEpoch}] INFO (${pid}): baz\n`
|
|
1253
|
+
)
|
|
1254
|
+
cb()
|
|
1255
|
+
}
|
|
1256
|
+
})
|
|
1257
|
+
const pretty = pinoPretty({
|
|
1258
|
+
destination,
|
|
1259
|
+
colorize: false
|
|
1260
|
+
})
|
|
1261
|
+
const log = pino({ messageKey: 'bar' }, pretty)
|
|
1262
|
+
log.info({ bar: 'baz' })
|
|
1263
|
+
})
|
|
1264
|
+
|
|
1265
|
+
test('handles customLogLevels', (t) => {
|
|
1266
|
+
t.plan(1)
|
|
1267
|
+
const destination = new Writable({
|
|
1268
|
+
write (formatted, enc, cb) {
|
|
1269
|
+
t.assert.strictEqual(
|
|
1270
|
+
formatted.toString(),
|
|
1271
|
+
`[${formattedEpoch}] TESTCUSTOM (${pid}): test message\n`
|
|
1272
|
+
)
|
|
1273
|
+
cb()
|
|
1274
|
+
}
|
|
1275
|
+
})
|
|
1276
|
+
const pretty = pinoPretty({
|
|
1277
|
+
destination,
|
|
1278
|
+
colorize: false
|
|
1279
|
+
})
|
|
1280
|
+
const log = pino({ customLevels: { testCustom: 35 } }, pretty)
|
|
1281
|
+
log.testCustom('test message')
|
|
1282
|
+
})
|
|
1283
|
+
})
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
function watchFileCreated (filename) {
|
|
1287
|
+
return new Promise((resolve, reject) => {
|
|
1288
|
+
const TIMEOUT = 2000
|
|
1289
|
+
const INTERVAL = 100
|
|
1290
|
+
const threshold = TIMEOUT / INTERVAL
|
|
1291
|
+
let counter = 0
|
|
1292
|
+
const interval = setInterval(() => {
|
|
1293
|
+
// On some CI runs file is created but not filled
|
|
1294
|
+
if (fs.existsSync(filename) && fs.statSync(filename).size !== 0) {
|
|
1295
|
+
clearInterval(interval)
|
|
1296
|
+
resolve()
|
|
1297
|
+
} else if (counter <= threshold) {
|
|
1298
|
+
counter++
|
|
1299
|
+
} else {
|
|
1300
|
+
clearInterval(interval)
|
|
1301
|
+
reject(new Error(`${filename} was not created.`))
|
|
1302
|
+
}
|
|
1303
|
+
}, INTERVAL)
|
|
1304
|
+
})
|
|
1305
|
+
}
|