@wbce/projen-d9 0.0.27 → 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 +185 -46
- package/API.md +153 -37
- package/CHANGELOG.md +20 -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/.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 +14 -7
- package/lib/cli/commands/init.d.ts +0 -1
- package/lib/cli/commands/init.js +0 -8
- package/lib/cli/commands/save/draft.js +0 -2
- package/node_modules/@types/node/globals.global.d.ts +0 -1
- /package/{lib/cli/commands/save/draft.d.ts → node_modules/pino/.nojekyll} +0 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { isColorSupported } = require('colorette')
|
|
4
|
+
const pump = require('pump')
|
|
5
|
+
const { Transform } = require('node:stream')
|
|
6
|
+
const abstractTransport = require('pino-abstract-transport')
|
|
7
|
+
const colors = require('./lib/colors')
|
|
8
|
+
const {
|
|
9
|
+
ERROR_LIKE_KEYS,
|
|
10
|
+
LEVEL_KEY,
|
|
11
|
+
LEVEL_LABEL,
|
|
12
|
+
MESSAGE_KEY,
|
|
13
|
+
TIMESTAMP_KEY
|
|
14
|
+
} = require('./lib/constants')
|
|
15
|
+
const {
|
|
16
|
+
buildSafeSonicBoom,
|
|
17
|
+
parseFactoryOptions
|
|
18
|
+
} = require('./lib/utils')
|
|
19
|
+
const pretty = require('./lib/pretty')
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {object} PinoPrettyOptions
|
|
23
|
+
* @property {boolean} [colorize] Indicates if colors should be used when
|
|
24
|
+
* prettifying. The default will be determined by the terminal capabilities at
|
|
25
|
+
* run time.
|
|
26
|
+
* @property {boolean} [colorizeObjects=true] Apply coloring to rendered objects
|
|
27
|
+
* when coloring is enabled.
|
|
28
|
+
* @property {boolean} [crlf=false] End lines with `\r\n` instead of `\n`.
|
|
29
|
+
* @property {string|null} [customColors=null] A comma separated list of colors
|
|
30
|
+
* to use for specific level labels, e.g. `err:red,info:blue`.
|
|
31
|
+
* @property {string|null} [customLevels=null] A comma separated list of user
|
|
32
|
+
* defined level names and numbers, e.g. `err:99,info:1`.
|
|
33
|
+
* @property {CustomPrettifiers} [customPrettifiers={}] A set of prettifier
|
|
34
|
+
* functions to apply to keys defined in this object.
|
|
35
|
+
* @property {K_ERROR_LIKE_KEYS} [errorLikeObjectKeys] A list of string property
|
|
36
|
+
* names to consider as error objects.
|
|
37
|
+
* @property {string} [errorProps=''] A comma separated list of properties on
|
|
38
|
+
* error objects to include in the output.
|
|
39
|
+
* @property {boolean} [hideObject=false] When `true`, data objects will be
|
|
40
|
+
* omitted from the output (except for error objects).
|
|
41
|
+
* @property {string} [ignore='hostname'] A comma separated list of log keys
|
|
42
|
+
* to omit when outputting the prettified log information.
|
|
43
|
+
* @property {undefined|string} [include=undefined] A comma separated list of
|
|
44
|
+
* log keys to include in the prettified log information. Only the keys in this
|
|
45
|
+
* list will be included in the output.
|
|
46
|
+
* @property {boolean} [levelFirst=false] When true, the log level will be the
|
|
47
|
+
* first field in the prettified output.
|
|
48
|
+
* @property {string} [levelKey='level'] The key name in the log data that
|
|
49
|
+
* contains the level value for the log.
|
|
50
|
+
* @property {string} [levelLabel='levelLabel'] Token name to use in
|
|
51
|
+
* `messageFormat` to represent the name of the logged level.
|
|
52
|
+
* @property {null|MessageFormatString|MessageFormatFunction} [messageFormat=null]
|
|
53
|
+
* When a string, defines how the prettified line should be formatted according
|
|
54
|
+
* to defined tokens. When a function, a synchronous function that returns a
|
|
55
|
+
* formatted string.
|
|
56
|
+
* @property {string} [messageKey='msg'] Defines the key in incoming logs that
|
|
57
|
+
* contains the message of the log, if present.
|
|
58
|
+
* @property {undefined|string|number} [minimumLevel=undefined] The minimum
|
|
59
|
+
* level for logs that should be processed. Any logs below this level will
|
|
60
|
+
* be omitted.
|
|
61
|
+
* @property {boolean} [singleLine=false] When `true` any objects, except error
|
|
62
|
+
* objects, in the log data will be printed as a single line instead as multiple
|
|
63
|
+
* lines.
|
|
64
|
+
* @property {string} [timestampKey='time'] Defines the key in incoming logs
|
|
65
|
+
* that contains the timestamp of the log, if present.
|
|
66
|
+
* @property {boolean|string} [translateTime=true] When true, will translate a
|
|
67
|
+
* JavaScript date integer into a human-readable string. If set to a string,
|
|
68
|
+
* it must be a format string.
|
|
69
|
+
* @property {boolean} [useOnlyCustomProps=true] When true, only custom levels
|
|
70
|
+
* and colors will be used if they have been provided.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The default options that will be used when prettifying log lines.
|
|
75
|
+
*
|
|
76
|
+
* @type {PinoPrettyOptions}
|
|
77
|
+
*/
|
|
78
|
+
const defaultOptions = {
|
|
79
|
+
colorize: isColorSupported,
|
|
80
|
+
colorizeObjects: true,
|
|
81
|
+
crlf: false,
|
|
82
|
+
customColors: null,
|
|
83
|
+
customLevels: null,
|
|
84
|
+
customPrettifiers: {},
|
|
85
|
+
errorLikeObjectKeys: ERROR_LIKE_KEYS,
|
|
86
|
+
errorProps: '',
|
|
87
|
+
hideObject: false,
|
|
88
|
+
ignore: 'hostname',
|
|
89
|
+
include: undefined,
|
|
90
|
+
levelFirst: false,
|
|
91
|
+
levelKey: LEVEL_KEY,
|
|
92
|
+
levelLabel: LEVEL_LABEL,
|
|
93
|
+
messageFormat: null,
|
|
94
|
+
messageKey: MESSAGE_KEY,
|
|
95
|
+
minimumLevel: undefined,
|
|
96
|
+
singleLine: false,
|
|
97
|
+
timestampKey: TIMESTAMP_KEY,
|
|
98
|
+
translateTime: true,
|
|
99
|
+
useOnlyCustomProps: true
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Normalizes a value to a boolean if it's the string "true" or "false".
|
|
104
|
+
* Otherwise returns the value unchanged.
|
|
105
|
+
*
|
|
106
|
+
* @param {any} value The value to normalize
|
|
107
|
+
* @returns {any} The normalized value
|
|
108
|
+
*/
|
|
109
|
+
function normalizeBoolean (value) {
|
|
110
|
+
if (value === 'true') return true
|
|
111
|
+
if (value === 'false') return false
|
|
112
|
+
return value
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Normalizes boolean options by converting "true" and "false" strings to booleans.
|
|
117
|
+
*
|
|
118
|
+
* @param {PinoPrettyOptions} options The options to normalize
|
|
119
|
+
* @returns {PinoPrettyOptions} The normalized options
|
|
120
|
+
*/
|
|
121
|
+
function normalizeBooleanOptions (options) {
|
|
122
|
+
const normalized = { ...options }
|
|
123
|
+
const booleanOptions = [
|
|
124
|
+
'colorize',
|
|
125
|
+
'colorizeObjects',
|
|
126
|
+
'crlf',
|
|
127
|
+
'hideObject',
|
|
128
|
+
'levelFirst',
|
|
129
|
+
'singleLine',
|
|
130
|
+
'useOnlyCustomProps'
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
for (const key of booleanOptions) {
|
|
134
|
+
if (key in normalized) {
|
|
135
|
+
normalized[key] = normalizeBoolean(normalized[key])
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// translateTime can be boolean or string (format string)
|
|
140
|
+
// Only normalize if it's exactly "true" or "false"
|
|
141
|
+
if ('translateTime' in normalized && (normalized.translateTime === 'true' || normalized.translateTime === 'false')) {
|
|
142
|
+
normalized.translateTime = normalizeBoolean(normalized.translateTime)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return normalized
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Processes the supplied options and returns a function that accepts log data
|
|
150
|
+
* and produces a prettified log string.
|
|
151
|
+
*
|
|
152
|
+
* @param {PinoPrettyOptions} options Configuration for the prettifier.
|
|
153
|
+
* @returns {LogPrettifierFunc}
|
|
154
|
+
*/
|
|
155
|
+
function prettyFactory (options) {
|
|
156
|
+
const mergedOptions = Object.assign({}, defaultOptions, options)
|
|
157
|
+
const normalizedOptions = normalizeBooleanOptions(mergedOptions)
|
|
158
|
+
const context = parseFactoryOptions(normalizedOptions)
|
|
159
|
+
return pretty.bind({ ...context, context })
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @typedef {PinoPrettyOptions} BuildStreamOpts
|
|
164
|
+
* @property {object|number|string} [destination] A destination stream, file
|
|
165
|
+
* descriptor, or target path to a file.
|
|
166
|
+
* @property {boolean} [append]
|
|
167
|
+
* @property {boolean} [mkdir]
|
|
168
|
+
* @property {boolean} [sync=false]
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Constructs a {@link LogPrettifierFunc} and a stream to which the produced
|
|
173
|
+
* prettified log data will be written.
|
|
174
|
+
*
|
|
175
|
+
* @param {BuildStreamOpts} opts
|
|
176
|
+
* @returns {Transform | (Transform & OnUnknown)}
|
|
177
|
+
*/
|
|
178
|
+
function build (opts = {}) {
|
|
179
|
+
let pretty = prettyFactory(opts)
|
|
180
|
+
let destination
|
|
181
|
+
return abstractTransport(function (source) {
|
|
182
|
+
source.on('message', function pinoConfigListener (message) {
|
|
183
|
+
if (!message || message.code !== 'PINO_CONFIG') return
|
|
184
|
+
Object.assign(opts, {
|
|
185
|
+
messageKey: message.config.messageKey,
|
|
186
|
+
errorLikeObjectKeys: Array.from(new Set([...(opts.errorLikeObjectKeys || ERROR_LIKE_KEYS), message.config.errorKey])),
|
|
187
|
+
customLevels: message.config.levels.values
|
|
188
|
+
})
|
|
189
|
+
pretty = prettyFactory(opts)
|
|
190
|
+
source.off('message', pinoConfigListener)
|
|
191
|
+
})
|
|
192
|
+
const stream = new Transform({
|
|
193
|
+
objectMode: true,
|
|
194
|
+
autoDestroy: true,
|
|
195
|
+
transform (chunk, enc, cb) {
|
|
196
|
+
const line = pretty(chunk)
|
|
197
|
+
cb(null, line)
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
if (typeof opts.destination === 'object' && typeof opts.destination.write === 'function') {
|
|
202
|
+
destination = opts.destination
|
|
203
|
+
} else {
|
|
204
|
+
destination = buildSafeSonicBoom({
|
|
205
|
+
dest: opts.destination || 1,
|
|
206
|
+
append: opts.append,
|
|
207
|
+
mkdir: opts.mkdir,
|
|
208
|
+
sync: opts.sync // by default sonic will be async
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
source.on('unknown', function (line) {
|
|
213
|
+
destination.write(line + '\n')
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
pump(source, stream, destination)
|
|
217
|
+
return stream
|
|
218
|
+
}, {
|
|
219
|
+
parse: 'lines',
|
|
220
|
+
close (err, cb) {
|
|
221
|
+
destination.on('close', () => {
|
|
222
|
+
cb(err)
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
module.exports = build
|
|
229
|
+
module.exports.build = build
|
|
230
|
+
module.exports.PinoPretty = build
|
|
231
|
+
module.exports.prettyFactory = prettyFactory
|
|
232
|
+
module.exports.colorizerFactory = colors
|
|
233
|
+
module.exports.isColorSupported = isColorSupported
|
|
234
|
+
module.exports.default = build
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const nocolor = input => input
|
|
4
|
+
const plain = {
|
|
5
|
+
default: nocolor,
|
|
6
|
+
60: nocolor,
|
|
7
|
+
50: nocolor,
|
|
8
|
+
40: nocolor,
|
|
9
|
+
30: nocolor,
|
|
10
|
+
20: nocolor,
|
|
11
|
+
10: nocolor,
|
|
12
|
+
message: nocolor,
|
|
13
|
+
greyMessage: nocolor,
|
|
14
|
+
property: nocolor
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { createColors } = require('colorette')
|
|
18
|
+
const getLevelLabelData = require('./utils/get-level-label-data')
|
|
19
|
+
const availableColors = createColors({ useColor: true })
|
|
20
|
+
const { white, bgRed, red, yellow, green, blue, gray, cyan, magenta } = availableColors
|
|
21
|
+
|
|
22
|
+
const colored = {
|
|
23
|
+
default: white,
|
|
24
|
+
60: bgRed,
|
|
25
|
+
50: red,
|
|
26
|
+
40: yellow,
|
|
27
|
+
30: green,
|
|
28
|
+
20: blue,
|
|
29
|
+
10: gray,
|
|
30
|
+
message: cyan,
|
|
31
|
+
greyMessage: gray,
|
|
32
|
+
property: magenta
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function resolveCustomColoredColorizer (customColors) {
|
|
36
|
+
return customColors.reduce(
|
|
37
|
+
function (agg, [level, color]) {
|
|
38
|
+
agg[level] = typeof availableColors[color] === 'function' ? availableColors[color] : white
|
|
39
|
+
|
|
40
|
+
return agg
|
|
41
|
+
},
|
|
42
|
+
{ default: white, message: cyan, greyMessage: gray, property: magenta }
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function colorizeLevel (useOnlyCustomProps) {
|
|
47
|
+
return function (level, colorizer, { customLevels, customLevelNames } = {}) {
|
|
48
|
+
const [levelStr, levelNum] = getLevelLabelData(useOnlyCustomProps, customLevels, customLevelNames)(level)
|
|
49
|
+
|
|
50
|
+
return Object.prototype.hasOwnProperty.call(colorizer, levelNum) ? colorizer[levelNum](levelStr) : colorizer.default(levelStr)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function plainColorizer (useOnlyCustomProps) {
|
|
55
|
+
const newPlainColorizer = colorizeLevel(useOnlyCustomProps)
|
|
56
|
+
const customColoredColorizer = function (level, opts) {
|
|
57
|
+
return newPlainColorizer(level, plain, opts)
|
|
58
|
+
}
|
|
59
|
+
customColoredColorizer.message = plain.message
|
|
60
|
+
customColoredColorizer.greyMessage = plain.greyMessage
|
|
61
|
+
customColoredColorizer.property = plain.property
|
|
62
|
+
customColoredColorizer.colors = createColors({ useColor: false })
|
|
63
|
+
return customColoredColorizer
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function coloredColorizer (useOnlyCustomProps) {
|
|
67
|
+
const newColoredColorizer = colorizeLevel(useOnlyCustomProps)
|
|
68
|
+
const customColoredColorizer = function (level, opts) {
|
|
69
|
+
return newColoredColorizer(level, colored, opts)
|
|
70
|
+
}
|
|
71
|
+
customColoredColorizer.message = colored.message
|
|
72
|
+
customColoredColorizer.property = colored.property
|
|
73
|
+
customColoredColorizer.greyMessage = colored.greyMessage
|
|
74
|
+
customColoredColorizer.colors = availableColors
|
|
75
|
+
return customColoredColorizer
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function customColoredColorizerFactory (customColors, useOnlyCustomProps) {
|
|
79
|
+
const onlyCustomColored = resolveCustomColoredColorizer(customColors)
|
|
80
|
+
const customColored = useOnlyCustomProps ? onlyCustomColored : Object.assign({}, colored, onlyCustomColored)
|
|
81
|
+
const colorizeLevelCustom = colorizeLevel(useOnlyCustomProps)
|
|
82
|
+
|
|
83
|
+
const customColoredColorizer = function (level, opts) {
|
|
84
|
+
return colorizeLevelCustom(level, customColored, opts)
|
|
85
|
+
}
|
|
86
|
+
customColoredColorizer.colors = availableColors
|
|
87
|
+
customColoredColorizer.message = customColoredColorizer.message || customColored.message
|
|
88
|
+
customColoredColorizer.property = customColoredColorizer.property || customColored.property
|
|
89
|
+
customColoredColorizer.greyMessage = customColoredColorizer.greyMessage || customColored.greyMessage
|
|
90
|
+
|
|
91
|
+
return customColoredColorizer
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Applies colorization, if possible, to a string representing the passed in
|
|
96
|
+
* `level`. For example, the default colorizer will return a "green" colored
|
|
97
|
+
* string for the "info" level.
|
|
98
|
+
*
|
|
99
|
+
* @typedef {function} ColorizerFunc
|
|
100
|
+
* @param {string|number} level In either case, the input will map to a color
|
|
101
|
+
* for the specified level or to the color for `USERLVL` if the level is not
|
|
102
|
+
* recognized.
|
|
103
|
+
* @property {function} message Accepts one string parameter that will be
|
|
104
|
+
* colorized to a predefined color.
|
|
105
|
+
* @property {Colorette.Colorette} colors Available color functions based on `useColor` (or `colorize`) context
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Factory function get a function to colorized levels. The returned function
|
|
110
|
+
* also includes a `.message(str)` method to colorize strings.
|
|
111
|
+
*
|
|
112
|
+
* @param {boolean} [useColors=false] When `true` a function that applies standard
|
|
113
|
+
* terminal colors is returned.
|
|
114
|
+
* @param {array[]} [customColors] Tuple where first item of each array is the
|
|
115
|
+
* level index and the second item is the color
|
|
116
|
+
* @param {boolean} [useOnlyCustomProps] When `true`, only use the provided
|
|
117
|
+
* custom colors provided and not fallback to default
|
|
118
|
+
*
|
|
119
|
+
* @returns {ColorizerFunc} `function (level) {}` has a `.message(str)` method to
|
|
120
|
+
* apply colorization to a string. The core function accepts either an integer
|
|
121
|
+
* `level` or a `string` level. The integer level will map to a known level
|
|
122
|
+
* string or to `USERLVL` if not known. The string `level` will map to the same
|
|
123
|
+
* colors as the integer `level` and will also default to `USERLVL` if the given
|
|
124
|
+
* string is not a recognized level name.
|
|
125
|
+
*/
|
|
126
|
+
module.exports = function getColorizer (useColors = false, customColors, useOnlyCustomProps) {
|
|
127
|
+
if (useColors && customColors !== undefined) {
|
|
128
|
+
return customColoredColorizerFactory(customColors, useOnlyCustomProps)
|
|
129
|
+
} else if (useColors) {
|
|
130
|
+
return coloredColorizer(useOnlyCustomProps)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return plainColorizer(useOnlyCustomProps)
|
|
134
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { test } = require('node:test')
|
|
4
|
+
const getColorizer = require('./colors')
|
|
5
|
+
|
|
6
|
+
const testDefaultColorizer = getColorizer => t => {
|
|
7
|
+
const colorizer = getColorizer()
|
|
8
|
+
let colorized = colorizer(10)
|
|
9
|
+
t.assert.strictEqual(colorized, 'TRACE')
|
|
10
|
+
|
|
11
|
+
colorized = colorizer(20)
|
|
12
|
+
t.assert.strictEqual(colorized, 'DEBUG')
|
|
13
|
+
|
|
14
|
+
colorized = colorizer(30)
|
|
15
|
+
t.assert.strictEqual(colorized, 'INFO')
|
|
16
|
+
|
|
17
|
+
colorized = colorizer(40)
|
|
18
|
+
t.assert.strictEqual(colorized, 'WARN')
|
|
19
|
+
|
|
20
|
+
colorized = colorizer(50)
|
|
21
|
+
t.assert.strictEqual(colorized, 'ERROR')
|
|
22
|
+
|
|
23
|
+
colorized = colorizer(60)
|
|
24
|
+
t.assert.strictEqual(colorized, 'FATAL')
|
|
25
|
+
|
|
26
|
+
colorized = colorizer(900)
|
|
27
|
+
t.assert.strictEqual(colorized, 'USERLVL')
|
|
28
|
+
|
|
29
|
+
colorized = colorizer('info')
|
|
30
|
+
t.assert.strictEqual(colorized, 'INFO')
|
|
31
|
+
|
|
32
|
+
colorized = colorizer('use-default')
|
|
33
|
+
t.assert.strictEqual(colorized, 'USERLVL')
|
|
34
|
+
|
|
35
|
+
colorized = colorizer.message('foo')
|
|
36
|
+
t.assert.strictEqual(colorized, 'foo')
|
|
37
|
+
|
|
38
|
+
colorized = colorizer.greyMessage('foo')
|
|
39
|
+
t.assert.strictEqual(colorized, 'foo')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const testColoringColorizer = getColorizer => t => {
|
|
43
|
+
const colorizer = getColorizer(true)
|
|
44
|
+
let colorized = colorizer(10)
|
|
45
|
+
t.assert.strictEqual(colorized, '\u001B[90mTRACE\u001B[39m')
|
|
46
|
+
|
|
47
|
+
colorized = colorizer(20)
|
|
48
|
+
t.assert.strictEqual(colorized, '\u001B[34mDEBUG\u001B[39m')
|
|
49
|
+
|
|
50
|
+
colorized = colorizer(30)
|
|
51
|
+
t.assert.strictEqual(colorized, '\u001B[32mINFO\u001B[39m')
|
|
52
|
+
|
|
53
|
+
colorized = colorizer(40)
|
|
54
|
+
t.assert.strictEqual(colorized, '\u001B[33mWARN\u001B[39m')
|
|
55
|
+
|
|
56
|
+
colorized = colorizer(50)
|
|
57
|
+
t.assert.strictEqual(colorized, '\u001B[31mERROR\u001B[39m')
|
|
58
|
+
|
|
59
|
+
colorized = colorizer(60)
|
|
60
|
+
t.assert.strictEqual(colorized, '\u001B[41mFATAL\u001B[49m')
|
|
61
|
+
|
|
62
|
+
colorized = colorizer(900)
|
|
63
|
+
t.assert.strictEqual(colorized, '\u001B[37mUSERLVL\u001B[39m')
|
|
64
|
+
|
|
65
|
+
colorized = colorizer('info')
|
|
66
|
+
t.assert.strictEqual(colorized, '\u001B[32mINFO\u001B[39m')
|
|
67
|
+
|
|
68
|
+
colorized = colorizer('use-default')
|
|
69
|
+
t.assert.strictEqual(colorized, '\u001B[37mUSERLVL\u001B[39m')
|
|
70
|
+
|
|
71
|
+
colorized = colorizer.message('foo')
|
|
72
|
+
t.assert.strictEqual(colorized, '\u001B[36mfoo\u001B[39m')
|
|
73
|
+
|
|
74
|
+
colorized = colorizer.greyMessage('foo')
|
|
75
|
+
t.assert.strictEqual(colorized, '\u001B[90mfoo\u001B[39m')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const testCustomColoringColorizer = getColorizer => t => {
|
|
79
|
+
const customLevels = {
|
|
80
|
+
0: 'INFO',
|
|
81
|
+
1: 'ERR',
|
|
82
|
+
default: 'USERLVL'
|
|
83
|
+
}
|
|
84
|
+
const customLevelNames = {
|
|
85
|
+
info: 0,
|
|
86
|
+
err: 1
|
|
87
|
+
}
|
|
88
|
+
const customColors = [
|
|
89
|
+
[0, 'not-a-color'],
|
|
90
|
+
[1, 'red']
|
|
91
|
+
]
|
|
92
|
+
const opts = {
|
|
93
|
+
customLevels,
|
|
94
|
+
customLevelNames
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const colorizer = getColorizer(true, customColors)
|
|
98
|
+
const colorizerWithCustomPropUse = getColorizer(true, customColors, true)
|
|
99
|
+
let colorized = colorizer(1, opts)
|
|
100
|
+
t.assert.strictEqual(colorized, '\u001B[31mERR\u001B[39m')
|
|
101
|
+
|
|
102
|
+
colorized = colorizer(0, opts)
|
|
103
|
+
t.assert.strictEqual(colorized, '\u001B[37mINFO\u001B[39m')
|
|
104
|
+
|
|
105
|
+
colorized = colorizer(900)
|
|
106
|
+
t.assert.strictEqual(colorized, '\u001B[37mUSERLVL\u001B[39m')
|
|
107
|
+
|
|
108
|
+
colorized = colorizer('err', opts)
|
|
109
|
+
t.assert.strictEqual(colorized, '\u001B[31mERR\u001B[39m')
|
|
110
|
+
|
|
111
|
+
colorized = colorizer('info', opts)
|
|
112
|
+
t.assert.strictEqual(colorized, '\u001B[37mINFO\u001B[39m')
|
|
113
|
+
|
|
114
|
+
colorized = colorizer('use-default')
|
|
115
|
+
t.assert.strictEqual(colorized, '\u001B[37mUSERLVL\u001B[39m')
|
|
116
|
+
|
|
117
|
+
colorized = colorizer(40, opts)
|
|
118
|
+
t.assert.strictEqual(colorized, '\u001B[33mWARN\u001B[39m')
|
|
119
|
+
|
|
120
|
+
colorized = colorizerWithCustomPropUse(50, opts)
|
|
121
|
+
t.assert.strictEqual(colorized, '\u001B[37mUSERLVL\u001B[39m')
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
test('returns default colorizer - private export', testDefaultColorizer(getColorizer))
|
|
125
|
+
test('returns colorizing colorizer - private export', testColoringColorizer(getColorizer))
|
|
126
|
+
test('returns custom colorizing colorizer - private export', testCustomColoringColorizer(getColorizer))
|
|
127
|
+
|
|
128
|
+
test('custom props defaults to standard levels', t => {
|
|
129
|
+
const colorizer = getColorizer(true, [], true)
|
|
130
|
+
const colorized = colorizer('info')
|
|
131
|
+
t.assert.strictEqual(colorized, '\u001B[37mINFO\u001B[39m')
|
|
132
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A set of property names that indicate the value represents an error object.
|
|
5
|
+
*
|
|
6
|
+
* @typedef {string[]} K_ERROR_LIKE_KEYS
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
DATE_FORMAT: 'yyyy-mm-dd HH:MM:ss.l o',
|
|
11
|
+
DATE_FORMAT_SIMPLE: 'HH:MM:ss.l',
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @type {K_ERROR_LIKE_KEYS}
|
|
15
|
+
*/
|
|
16
|
+
ERROR_LIKE_KEYS: ['err', 'error'],
|
|
17
|
+
|
|
18
|
+
MESSAGE_KEY: 'msg',
|
|
19
|
+
|
|
20
|
+
LEVEL_KEY: 'level',
|
|
21
|
+
|
|
22
|
+
LEVEL_LABEL: 'levelLabel',
|
|
23
|
+
|
|
24
|
+
TIMESTAMP_KEY: 'time',
|
|
25
|
+
|
|
26
|
+
LEVELS: {
|
|
27
|
+
default: 'USERLVL',
|
|
28
|
+
60: 'FATAL',
|
|
29
|
+
50: 'ERROR',
|
|
30
|
+
40: 'WARN',
|
|
31
|
+
30: 'INFO',
|
|
32
|
+
20: 'DEBUG',
|
|
33
|
+
10: 'TRACE'
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
LEVEL_NAMES: {
|
|
37
|
+
fatal: 60,
|
|
38
|
+
error: 50,
|
|
39
|
+
warn: 40,
|
|
40
|
+
info: 30,
|
|
41
|
+
debug: 20,
|
|
42
|
+
trace: 10
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// Object keys that probably came from a logger like Pino or Bunyan.
|
|
46
|
+
LOGGER_KEYS: [
|
|
47
|
+
'pid',
|
|
48
|
+
'hostname',
|
|
49
|
+
'name',
|
|
50
|
+
'level',
|
|
51
|
+
'time',
|
|
52
|
+
'timestamp',
|
|
53
|
+
'caller'
|
|
54
|
+
]
|
|
55
|
+
}
|