@venizia/ignis-helpers 0.4.7-0 → 0.4.7-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -3
- package/README.md +7 -8
- package/dist/esm/common/redact.d.ts +25 -17
- package/dist/esm/common/redact.d.ts.map +1 -1
- package/dist/esm/common/redact.js +50 -46
- package/dist/esm/common/redact.js.map +1 -1
- package/dist/esm/common/resolvers.d.ts +7 -5
- package/dist/esm/common/resolvers.d.ts.map +1 -1
- package/dist/esm/common/resolvers.js +11 -9
- package/dist/esm/common/resolvers.js.map +1 -1
- package/dist/esm/core.d.ts +5 -3
- package/dist/esm/core.d.ts.map +1 -1
- package/dist/esm/core.js +7 -3
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/modules/base.d.ts +1 -1
- package/dist/esm/modules/base.d.ts.map +1 -1
- package/dist/esm/modules/base.js +14 -5
- package/dist/esm/modules/base.js.map +1 -1
- package/dist/esm/modules/cron/helper.js +4 -4
- package/dist/esm/modules/cron/helper.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes-legacy.algorithm.js +3 -3
- package/dist/esm/modules/crypto/algorithms/aes-legacy.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.js +5 -5
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/base.algorithm.js +3 -3
- package/dist/esm/modules/crypto/algorithms/base.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts +15 -5
- package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts.map +1 -1
- package/dist/esm/modules/crypto/algorithms/hash.algorithm.js +16 -4
- package/dist/esm/modules/crypto/algorithms/hash.algorithm.js.map +1 -1
- package/dist/esm/modules/env/app-env.d.ts.map +1 -1
- package/dist/esm/modules/env/app-env.js +2 -2
- package/dist/esm/modules/env/app-env.js.map +1 -1
- package/dist/esm/modules/logger/base/base.d.ts.map +1 -1
- package/dist/esm/modules/logger/base/base.js +3 -3
- package/dist/esm/modules/logger/base/base.js.map +1 -1
- package/dist/esm/modules/logger/base/console.d.ts +9 -4
- package/dist/esm/modules/logger/base/console.d.ts.map +1 -1
- package/dist/esm/modules/logger/base/console.js +15 -4
- package/dist/esm/modules/logger/base/console.js.map +1 -1
- package/dist/esm/modules/logger/common/constants.d.ts +23 -22
- package/dist/esm/modules/logger/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/logger/common/constants.js +43 -46
- package/dist/esm/modules/logger/common/constants.js.map +1 -1
- package/dist/esm/modules/logger/common/debug-gate.d.ts +33 -0
- package/dist/esm/modules/logger/common/debug-gate.d.ts.map +1 -0
- package/dist/esm/modules/logger/common/debug-gate.js +51 -0
- package/dist/esm/modules/logger/common/debug-gate.js.map +1 -0
- package/dist/esm/modules/logger/common/index.d.ts +1 -0
- package/dist/esm/modules/logger/common/index.d.ts.map +1 -1
- package/dist/esm/modules/logger/common/index.js +1 -0
- package/dist/esm/modules/logger/common/index.js.map +1 -1
- package/dist/esm/modules/logger/common/types.d.ts +7 -0
- package/dist/esm/modules/logger/common/types.d.ts.map +1 -1
- package/dist/esm/modules/logger/common/types.js +16 -0
- package/dist/esm/modules/logger/common/types.js.map +1 -1
- package/dist/esm/modules/logger/factory.d.ts +29 -10
- package/dist/esm/modules/logger/factory.d.ts.map +1 -1
- package/dist/esm/modules/logger/factory.js +108 -48
- package/dist/esm/modules/logger/factory.js.map +1 -1
- package/dist/esm/modules/logger/formatting/deep-splat.d.ts +10 -6
- package/dist/esm/modules/logger/formatting/deep-splat.d.ts.map +1 -1
- package/dist/esm/modules/logger/formatting/deep-splat.js +73 -62
- package/dist/esm/modules/logger/formatting/deep-splat.js.map +1 -1
- package/dist/esm/modules/logger/formatting/error-prettier.d.ts.map +1 -1
- package/dist/esm/modules/logger/formatting/error-prettier.js +8 -6
- package/dist/esm/modules/logger/formatting/error-prettier.js.map +1 -1
- package/dist/esm/modules/logger/hf/logger.d.ts.map +1 -1
- package/dist/esm/modules/logger/hf/logger.js +5 -5
- package/dist/esm/modules/logger/hf/logger.js.map +1 -1
- package/dist/esm/modules/logger/index.d.ts +0 -1
- package/dist/esm/modules/logger/index.d.ts.map +1 -1
- package/dist/esm/modules/logger/index.js +0 -1
- package/dist/esm/modules/logger/index.js.map +1 -1
- package/dist/esm/modules/logger/pino/backing.d.ts +0 -9
- package/dist/esm/modules/logger/pino/backing.d.ts.map +1 -1
- package/dist/esm/modules/logger/pino/backing.js +3 -8
- package/dist/esm/modules/logger/pino/backing.js.map +1 -1
- package/dist/esm/modules/logger/pino/destination.d.ts +6 -9
- package/dist/esm/modules/logger/pino/destination.d.ts.map +1 -1
- package/dist/esm/modules/logger/pino/destination.js +12 -13
- package/dist/esm/modules/logger/pino/destination.js.map +1 -1
- package/dist/esm/modules/logger/pino/logger.js +2 -2
- package/dist/esm/modules/logger/pino/logger.js.map +1 -1
- package/dist/esm/modules/logger/winston/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/logger/winston/common/constants.js +7 -6
- package/dist/esm/modules/logger/winston/common/constants.js.map +1 -1
- package/dist/esm/modules/logger/winston/define.d.ts +0 -7
- package/dist/esm/modules/logger/winston/define.d.ts.map +1 -1
- package/dist/esm/modules/logger/winston/define.js +0 -5
- package/dist/esm/modules/logger/winston/define.js.map +1 -1
- package/dist/esm/modules/logger/winston/formats.d.ts +2 -0
- package/dist/esm/modules/logger/winston/formats.d.ts.map +1 -1
- package/dist/esm/modules/logger/winston/formats.js +17 -4
- package/dist/esm/modules/logger/winston/formats.js.map +1 -1
- package/dist/esm/modules/logger/winston/index.d.ts +3 -2
- package/dist/esm/modules/logger/winston/index.d.ts.map +1 -1
- package/dist/esm/modules/logger/winston/index.js +3 -2
- package/dist/esm/modules/logger/winston/index.js.map +1 -1
- package/dist/esm/modules/logger/winston/logger-factory.js +4 -4
- package/dist/esm/modules/logger/winston/logger-factory.js.map +1 -1
- package/dist/esm/modules/network/http-request/base-network-request.helper.js +2 -2
- package/dist/esm/modules/network/http-request/base-network-request.helper.js.map +1 -1
- package/dist/esm/modules/network/http-request/common/index.d.ts +0 -1
- package/dist/esm/modules/network/http-request/common/index.d.ts.map +1 -1
- package/dist/esm/modules/network/http-request/common/index.js +0 -1
- package/dist/esm/modules/network/http-request/common/index.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js +4 -2
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +6 -4
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +4 -4
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +4 -4
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
- package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js +2 -2
- package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js.map +1 -1
- package/dist/esm/modules/network/utilities/query-string.d.ts +22 -20
- package/dist/esm/modules/network/utilities/query-string.d.ts.map +1 -1
- package/dist/esm/modules/network/utilities/query-string.js +48 -46
- package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
- package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts +0 -10
- package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts.map +1 -1
- package/dist/esm/modules/network/utilities/url-safety/common/errors.js +0 -11
- package/dist/esm/modules/network/utilities/url-safety/common/errors.js.map +1 -1
- package/dist/esm/modules/network/utilities/url-safety/policy.d.ts +10 -0
- package/dist/esm/modules/network/utilities/url-safety/policy.d.ts.map +1 -1
- package/dist/esm/modules/network/utilities/url-safety/policy.js +11 -0
- package/dist/esm/modules/network/utilities/url-safety/policy.js.map +1 -1
- package/dist/esm/modules/queue/bullmq/helper.d.ts.map +1 -1
- package/dist/esm/modules/queue/bullmq/helper.js +6 -6
- package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
- package/dist/esm/modules/queue/common/hook.d.ts +14 -12
- package/dist/esm/modules/queue/common/hook.d.ts.map +1 -1
- package/dist/esm/modules/queue/common/hook.js +21 -19
- package/dist/esm/modules/queue/common/hook.js.map +1 -1
- package/dist/esm/modules/queue/common/index.d.ts +0 -1
- package/dist/esm/modules/queue/common/index.d.ts.map +1 -1
- package/dist/esm/modules/queue/common/index.js +0 -1
- package/dist/esm/modules/queue/common/index.js.map +1 -1
- package/dist/esm/modules/queue/internal/sequential/helper.js +8 -8
- package/dist/esm/modules/queue/internal/sequential/helper.js.map +1 -1
- package/dist/esm/modules/queue/kafka/base.js +3 -3
- package/dist/esm/modules/queue/kafka/base.js.map +1 -1
- package/dist/esm/modules/queue/kafka/bundler/index.d.ts +0 -2
- package/dist/esm/modules/queue/kafka/bundler/index.d.ts.map +1 -1
- package/dist/esm/modules/queue/kafka/bundler/index.js +0 -2
- package/dist/esm/modules/queue/kafka/bundler/index.js.map +1 -1
- package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts +8 -2
- package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts.map +1 -1
- package/dist/esm/modules/queue/kafka/bundler/plugins.js +64 -7
- package/dist/esm/modules/queue/kafka/bundler/plugins.js.map +1 -1
- package/dist/esm/modules/queue/kafka/consumer.d.ts.map +1 -1
- package/dist/esm/modules/queue/kafka/consumer.js +22 -22
- package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
- package/dist/esm/modules/queue/mqtt/helper.js +10 -10
- package/dist/esm/modules/queue/mqtt/helper.js.map +1 -1
- package/dist/esm/modules/redis/base/abstract.helper.js +8 -8
- package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
- package/dist/esm/modules/redis/cluster/cluster.helper.js +2 -2
- package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
- package/dist/esm/modules/redis/factory.d.ts +13 -9
- package/dist/esm/modules/redis/factory.d.ts.map +1 -1
- package/dist/esm/modules/redis/factory.js +15 -13
- package/dist/esm/modules/redis/factory.js.map +1 -1
- package/dist/esm/modules/redis/sentinel/sentinel.helper.js +2 -2
- package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
- package/dist/esm/modules/redis/single/single.helper.js +2 -2
- package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
- package/dist/esm/modules/redis/utility.d.ts +13 -11
- package/dist/esm/modules/redis/utility.d.ts.map +1 -1
- package/dist/esm/modules/redis/utility.js +46 -44
- package/dist/esm/modules/redis/utility.js.map +1 -1
- package/dist/esm/modules/retry/helper.js +2 -2
- package/dist/esm/modules/retry/helper.js.map +1 -1
- package/dist/esm/modules/secrets/factory.d.ts +5 -3
- package/dist/esm/modules/secrets/factory.d.ts.map +1 -1
- package/dist/esm/modules/secrets/factory.js +36 -34
- package/dist/esm/modules/secrets/factory.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/server/helper.d.ts.map +1 -1
- package/dist/esm/modules/socket/socket-io/server/helper.js +11 -11
- package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
- package/dist/esm/modules/socket/websocket/emitter/helper.d.ts.map +1 -1
- package/dist/esm/modules/socket/websocket/emitter/helper.js +3 -3
- package/dist/esm/modules/socket/websocket/emitter/helper.js.map +1 -1
- package/dist/esm/modules/socket/websocket/server/delivery.d.ts.map +1 -1
- package/dist/esm/modules/socket/websocket/server/delivery.js +5 -6
- package/dist/esm/modules/socket/websocket/server/delivery.js.map +1 -1
- package/dist/esm/modules/socket/websocket/server/helper.d.ts.map +1 -1
- package/dist/esm/modules/socket/websocket/server/helper.js +7 -7
- package/dist/esm/modules/socket/websocket/server/helper.js.map +1 -1
- package/dist/esm/modules/storage/base.js +7 -7
- package/dist/esm/modules/storage/base.js.map +1 -1
- package/dist/esm/modules/storage/bun-s3/helper.d.ts.map +1 -1
- package/dist/esm/modules/storage/bun-s3/helper.js +25 -18
- package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
- package/dist/esm/modules/storage/bun-s3/utility.d.ts +95 -77
- package/dist/esm/modules/storage/bun-s3/utility.d.ts.map +1 -1
- package/dist/esm/modules/storage/bun-s3/utility.js +261 -239
- package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
- package/dist/esm/modules/storage/common/errors.d.ts +0 -4
- package/dist/esm/modules/storage/common/errors.d.ts.map +1 -1
- package/dist/esm/modules/storage/common/errors.js +0 -10
- package/dist/esm/modules/storage/common/errors.js.map +1 -1
- package/dist/esm/modules/storage/common/utility.d.ts +11 -5
- package/dist/esm/modules/storage/common/utility.d.ts.map +1 -1
- package/dist/esm/modules/storage/common/utility.js +30 -17
- package/dist/esm/modules/storage/common/utility.js.map +1 -1
- package/dist/esm/modules/uid/uuid/helper.d.ts +1 -1
- package/dist/esm/modules/uid/uuid/helper.d.ts.map +1 -1
- package/dist/esm/modules/uid/uuid/helper.js +7 -7
- package/dist/esm/modules/uid/uuid/helper.js.map +1 -1
- package/dist/esm/modules/uid/uuid/v4.d.ts +11 -8
- package/dist/esm/modules/uid/uuid/v4.d.ts.map +1 -1
- package/dist/esm/modules/uid/uuid/v4.js +51 -46
- package/dist/esm/modules/uid/uuid/v4.js.map +1 -1
- package/dist/esm/modules/uid/uuid/v5.d.ts +17 -14
- package/dist/esm/modules/uid/uuid/v5.d.ts.map +1 -1
- package/dist/esm/modules/uid/uuid/v5.js +83 -78
- package/dist/esm/modules/uid/uuid/v5.js.map +1 -1
- package/dist/esm/modules/uid/uuid/v7.d.ts +15 -10
- package/dist/esm/modules/uid/uuid/v7.d.ts.map +1 -1
- package/dist/esm/modules/uid/uuid/v7.js +88 -79
- package/dist/esm/modules/uid/uuid/v7.js.map +1 -1
- package/dist/esm/modules/worker-thread/bus/base.js +2 -2
- package/dist/esm/modules/worker-thread/bus/base.js.map +1 -1
- package/dist/esm/modules/worker-thread/worker/base.d.ts.map +1 -1
- package/dist/esm/modules/worker-thread/worker/base.js +4 -3
- package/dist/esm/modules/worker-thread/worker/base.js.map +1 -1
- package/dist/esm/utilities/error.utility.d.ts +7 -0
- package/dist/esm/utilities/error.utility.d.ts.map +1 -0
- package/dist/esm/utilities/error.utility.js +9 -0
- package/dist/esm/utilities/error.utility.js.map +1 -0
- package/dist/esm/utilities/form-body.utility.d.ts +12 -10
- package/dist/esm/utilities/form-body.utility.d.ts.map +1 -1
- package/dist/esm/utilities/form-body.utility.js +19 -17
- package/dist/esm/utilities/form-body.utility.js.map +1 -1
- package/dist/esm/utilities/hr-time.utility.d.ts +7 -5
- package/dist/esm/utilities/hr-time.utility.d.ts.map +1 -1
- package/dist/esm/utilities/hr-time.utility.js +11 -9
- package/dist/esm/utilities/hr-time.utility.js.map +1 -1
- package/dist/esm/utilities/index.d.ts +2 -2
- package/dist/esm/utilities/index.d.ts.map +1 -1
- package/dist/esm/utilities/index.js +2 -2
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/module.utility.d.ts.map +1 -1
- package/dist/esm/utilities/module.utility.js +1 -0
- package/dist/esm/utilities/module.utility.js.map +1 -1
- package/dist/esm/utilities/parse.utility.d.ts +89 -43
- package/dist/esm/utilities/parse.utility.d.ts.map +1 -1
- package/dist/esm/utilities/parse.utility.js +173 -141
- package/dist/esm/utilities/parse.utility.js.map +1 -1
- package/dist/esm/utilities/performance.utility.d.ts +15 -13
- package/dist/esm/utilities/performance.utility.d.ts.map +1 -1
- package/dist/esm/utilities/performance.utility.js +34 -29
- package/dist/esm/utilities/performance.utility.js.map +1 -1
- package/dist/esm/utilities/promise.utility.d.ts +20 -18
- package/dist/esm/utilities/promise.utility.d.ts.map +1 -1
- package/dist/esm/utilities/promise.utility.js +41 -51
- package/dist/esm/utilities/promise.utility.js.map +1 -1
- package/dist/esm/utilities/request.utility.d.ts +35 -29
- package/dist/esm/utilities/request.utility.d.ts.map +1 -1
- package/dist/esm/utilities/request.utility.js +118 -115
- package/dist/esm/utilities/request.utility.js.map +1 -1
- package/package.json +4 -15
- package/dist/esm/modules/logger/resolver.d.ts +0 -33
- package/dist/esm/modules/logger/resolver.d.ts.map +0 -1
- package/dist/esm/modules/logger/resolver.js +0 -95
- package/dist/esm/modules/logger/resolver.js.map +0 -1
- package/dist/esm/modules/logger/slot.d.ts +0 -23
- package/dist/esm/modules/logger/slot.d.ts.map +0 -1
- package/dist/esm/modules/logger/slot.js +0 -119
- package/dist/esm/modules/logger/slot.js.map +0 -1
- package/dist/esm/modules/logger/winston/formatters/deep-splat.d.ts +0 -4
- package/dist/esm/modules/logger/winston/formatters/deep-splat.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/formatters/deep-splat.js +0 -14
- package/dist/esm/modules/logger/winston/formatters/deep-splat.js.map +0 -1
- package/dist/esm/modules/logger/winston/formatters/index.d.ts +0 -2
- package/dist/esm/modules/logger/winston/formatters/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/formatters/index.js +0 -2
- package/dist/esm/modules/logger/winston/formatters/index.js.map +0 -1
- package/dist/esm/modules/network/http-request/common/types.d.ts +0 -2
- package/dist/esm/modules/network/http-request/common/types.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/common/types.js +0 -2
- package/dist/esm/modules/network/http-request/common/types.js.map +0 -1
- package/dist/esm/modules/queue/common/types.d.ts +0 -2
- package/dist/esm/modules/queue/common/types.d.ts.map +0 -1
- package/dist/esm/modules/queue/common/types.js +0 -2
- package/dist/esm/modules/queue/common/types.js.map +0 -1
- package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.d.ts +0 -4
- package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.js +0 -28
- package/dist/esm/modules/queue/kafka/bundler/platformatic-require.plugin.js.map +0 -1
- package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.d.ts +0 -4
- package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.js +0 -26
- package/dist/esm/modules/queue/kafka/bundler/platformatic-wasm.plugin.js.map +0 -1
- package/dist/esm/modules/storage/minio/helper.d.ts +0 -55
- package/dist/esm/modules/storage/minio/helper.d.ts.map +0 -1
- package/dist/esm/modules/storage/minio/helper.js +0 -177
- package/dist/esm/modules/storage/minio/helper.js.map +0 -1
- package/dist/esm/modules/storage/minio/index.d.ts +0 -2
- package/dist/esm/modules/storage/minio/index.d.ts.map +0 -1
- package/dist/esm/modules/storage/minio/index.js +0 -2
- package/dist/esm/modules/storage/minio/index.js.map +0 -1
- package/dist/esm/utilities/sleep.utility.d.ts +0 -2
- package/dist/esm/utilities/sleep.utility.d.ts.map +0 -1
- package/dist/esm/utilities/sleep.utility.js +0 -4
- package/dist/esm/utilities/sleep.utility.js.map +0 -1
|
@@ -1,37 +1,70 @@
|
|
|
1
|
-
import { getError } from '@venizia/ignis-inversion';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
1
|
import { AbstractLogger } from './base/abstract.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { ConsoleLogger } from './base/console.js';
|
|
3
|
+
import { LoggerDebugGate } from './common/debug-gate.js';
|
|
4
|
+
import { LogLevels } from './common/types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Stable wrapper the factory hands out. The delegate is resolved on the first log call or by `use()`, never at
|
|
7
|
+
* construction, so no provider is touched until a line is written. The wrapper also applies the factory's level to every
|
|
8
|
+
* provider the same way. Mutual reference with LoggerFactory is by design - hence the `no-use-before-define` disables.
|
|
9
|
+
*/
|
|
6
10
|
class LoggerDelegator extends AbstractLogger {
|
|
7
11
|
constructor(scope) {
|
|
8
12
|
super();
|
|
9
13
|
this.scope = scope;
|
|
14
|
+
this._generation = -1;
|
|
10
15
|
}
|
|
16
|
+
/** Takes the new provider's logger for this scope at once: the wrappers of this copy do not wait for their next line. */
|
|
11
17
|
repoint(provider) {
|
|
12
18
|
this._delegate = provider.get(this.scope);
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
20
|
+
this._generation = LoggerFactory.currentGeneration();
|
|
13
21
|
}
|
|
22
|
+
/** The provider's logger for this scope, taken again whenever any copy of the module chose another provider (one integer compare per line). */
|
|
14
23
|
delegate() {
|
|
15
24
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
16
|
-
|
|
25
|
+
const generation = LoggerFactory.currentGeneration();
|
|
26
|
+
if (!this._delegate || this._generation !== generation) {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
28
|
+
this._delegate = LoggerFactory.currentProvider().get(this.scope);
|
|
29
|
+
this._generation = generation;
|
|
30
|
+
}
|
|
31
|
+
return this._delegate;
|
|
32
|
+
}
|
|
33
|
+
/** The level the application set, else the shared debug gate for `debug`: a provider that has no gate of its own is gated the same way. */
|
|
34
|
+
isEnabled(level) {
|
|
35
|
+
if (level === LogLevels.DEBUG && !LoggerDebugGate.isOpen()) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
39
|
+
const threshold = LoggerFactory.currentLevel();
|
|
40
|
+
return threshold === undefined || LogLevels.isEnabled({ level, threshold });
|
|
41
|
+
}
|
|
42
|
+
/** The one place a level method passes its line to the provider, after the one level check. */
|
|
43
|
+
forward(opts) {
|
|
44
|
+
const { method, message, args } = opts;
|
|
45
|
+
if (this.isEnabled(method)) {
|
|
46
|
+
this.delegate()[method](message, ...args);
|
|
47
|
+
}
|
|
17
48
|
}
|
|
18
49
|
debug(message, ...args) {
|
|
19
|
-
this.
|
|
50
|
+
this.forward({ method: LogLevels.DEBUG, message, args });
|
|
20
51
|
}
|
|
21
52
|
info(message, ...args) {
|
|
22
|
-
this.
|
|
53
|
+
this.forward({ method: LogLevels.INFO, message, args });
|
|
23
54
|
}
|
|
24
55
|
warn(message, ...args) {
|
|
25
|
-
this.
|
|
56
|
+
this.forward({ method: LogLevels.WARN, message, args });
|
|
26
57
|
}
|
|
27
58
|
error(message, ...args) {
|
|
28
|
-
this.
|
|
59
|
+
this.forward({ method: LogLevels.ERROR, message, args });
|
|
29
60
|
}
|
|
30
61
|
emerg(message, ...args) {
|
|
31
|
-
this.
|
|
62
|
+
this.forward({ method: LogLevels.EMERG, message, args });
|
|
32
63
|
}
|
|
33
64
|
log(level, message, ...args) {
|
|
34
|
-
this.
|
|
65
|
+
if (this.isEnabled(level)) {
|
|
66
|
+
this.delegate().log(level, message, ...args);
|
|
67
|
+
}
|
|
35
68
|
}
|
|
36
69
|
for(methodName) {
|
|
37
70
|
const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;
|
|
@@ -39,52 +72,85 @@ class LoggerDelegator extends AbstractLogger {
|
|
|
39
72
|
return LoggerFactory.getLogger([childScope]);
|
|
40
73
|
}
|
|
41
74
|
}
|
|
42
|
-
/** A bundle can carry two copies of this module - the application's ESM import and core's CJS require. The provider
|
|
75
|
+
/** A bundle can carry two copies of this module - the application's ESM import and core's CJS require. The chosen provider, the level and a counter of choices live in these globalThis slots so `use()` in one copy is seen, on the next line, by the loggers of the other. */
|
|
43
76
|
const PROVIDER_SLOT = Symbol.for('ignis:logger-provider');
|
|
44
|
-
|
|
77
|
+
const LEVEL_SLOT = Symbol.for('ignis:logger-level');
|
|
78
|
+
const GENERATION_SLOT = Symbol.for('ignis:logger-generation');
|
|
79
|
+
/**
|
|
80
|
+
* The one way to get a logger, and the same everywhere: the server, a script and a browser. It names no provider: the
|
|
81
|
+
* default is the console (`ConsoleLogger`), and an application chooses another with `use()`. It imports nothing from
|
|
82
|
+
* node, so it is part of the browser-pure `core` entry.
|
|
83
|
+
*/
|
|
45
84
|
export class LoggerFactory {
|
|
46
85
|
static { this.cache = new Map(); }
|
|
47
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Choose the application's provider and/or the level. A provider re-points every wrapper issued so far. The level
|
|
88
|
+
* (a `LogLevels` value the application passes) is applied by the wrapper to every provider alike, and it also
|
|
89
|
+
* decides whether `debug` lines are written at all: `debug` turns the gate on, anything above it turns it off,
|
|
90
|
+
* whatever the environment says. A level that is not a `LogLevels` value (a typo, an uppercase name from the
|
|
91
|
+
* environment) is ignored: it must never open debug.
|
|
92
|
+
*/
|
|
48
93
|
static use(opts) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
94
|
+
const { provider, level } = opts;
|
|
95
|
+
if (level !== undefined && LogLevels.isValid(level)) {
|
|
96
|
+
Reflect.set(globalThis, LEVEL_SLOT, level);
|
|
97
|
+
LoggerDebugGate.force({
|
|
98
|
+
isOpen: LogLevels.isEnabled({ level: LogLevels.DEBUG, threshold: level }),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (provider === undefined) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
Reflect.set(globalThis, PROVIDER_SLOT, provider);
|
|
105
|
+
this.bumpGeneration();
|
|
106
|
+
for (const wrapper of this.cache.values()) {
|
|
107
|
+
wrapper.repoint(provider);
|
|
54
108
|
}
|
|
55
109
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
110
|
+
/** Choose `provider` only when the application has not chosen one: a framework's startup default, never an override. */
|
|
111
|
+
static useUnlessChosen(opts) {
|
|
112
|
+
if (!this.isChosen()) {
|
|
113
|
+
this.use({ provider: opts.provider });
|
|
60
114
|
}
|
|
61
|
-
return this.provider;
|
|
62
115
|
}
|
|
63
|
-
/**
|
|
116
|
+
/** Whether an application (or a framework default through `useUnlessChosen`) has chosen a provider. */
|
|
117
|
+
static isChosen() {
|
|
118
|
+
return this.sharedProvider() !== undefined;
|
|
119
|
+
}
|
|
120
|
+
/** The slot is the only record of the choice, so a `use()` or a `reset()` in any copy of the module is seen by all. */
|
|
121
|
+
static currentProvider() {
|
|
122
|
+
return this.sharedProvider() ?? ConsoleLogger;
|
|
123
|
+
}
|
|
124
|
+
/** Moves whenever a provider is chosen or reset, in any copy: a wrapper that cached its logger takes it again. */
|
|
125
|
+
static currentGeneration() {
|
|
126
|
+
const generation = Reflect.get(globalThis, GENERATION_SLOT);
|
|
127
|
+
return generation ?? 0;
|
|
128
|
+
}
|
|
129
|
+
static bumpGeneration() {
|
|
130
|
+
Reflect.set(globalThis, GENERATION_SLOT, this.currentGeneration() + 1);
|
|
131
|
+
}
|
|
132
|
+
/** The level the application set, or `undefined`: then every provider applies its own gate. */
|
|
133
|
+
static currentLevel() {
|
|
134
|
+
const level = Reflect.get(globalThis, LEVEL_SLOT);
|
|
135
|
+
return level;
|
|
136
|
+
}
|
|
137
|
+
/** The provider chosen by any copy of this module, if any. */
|
|
64
138
|
static sharedProvider() {
|
|
65
139
|
const shared = Reflect.get(globalThis, PROVIDER_SLOT);
|
|
66
140
|
return shared;
|
|
67
141
|
}
|
|
68
|
-
|
|
69
|
-
static
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
'[LoggerFactory] No logger provider is registered and the default (winston) could not be loaded.',
|
|
77
|
-
'Either install it: `bun add winston winston-transport winston-daily-rotate-file`,',
|
|
78
|
-
'or register a provider at your entrypoint: `LoggerFactory.use({ provider })` with a class',
|
|
79
|
-
"from '@venizia/ignis-helpers/winston' or '@venizia/ignis-helpers/pino'.",
|
|
80
|
-
'Compiled binaries (bun build --compile) MUST register explicitly.',
|
|
81
|
-
`Cause: ${error instanceof Error ? error.message : String(error)}`,
|
|
82
|
-
].join(' '),
|
|
83
|
-
});
|
|
142
|
+
/** Back to the default provider and no level, and every wrapper takes the console again: for a test, or a host that starts over. */
|
|
143
|
+
static reset() {
|
|
144
|
+
Reflect.deleteProperty(globalThis, PROVIDER_SLOT);
|
|
145
|
+
Reflect.deleteProperty(globalThis, LEVEL_SLOT);
|
|
146
|
+
LoggerDebugGate.force({ isOpen: undefined });
|
|
147
|
+
this.bumpGeneration();
|
|
148
|
+
for (const wrapper of this.cache.values()) {
|
|
149
|
+
wrapper.repoint(ConsoleLogger);
|
|
84
150
|
}
|
|
85
151
|
}
|
|
86
152
|
static getLogger(scopes) {
|
|
87
|
-
const scope = scopes.join('-');
|
|
153
|
+
const scope = scopes.filter((part) => part.length > 0).join('-');
|
|
88
154
|
let cached = this.cache.get(scope);
|
|
89
155
|
if (!cached) {
|
|
90
156
|
cached = new LoggerDelegator(scope);
|
|
@@ -93,10 +159,4 @@ export class LoggerFactory {
|
|
|
93
159
|
return cached;
|
|
94
160
|
}
|
|
95
161
|
}
|
|
96
|
-
/** Provider-following facade: always resolves through the registered provider. */
|
|
97
|
-
export const ApplicationLogger = {
|
|
98
|
-
get: (scope) => LoggerFactory.getLogger([scope]),
|
|
99
|
-
};
|
|
100
|
-
// Runs whenever LoggerFactory is imported as a value - which core's Container and every application entrypoint already do. This is what makes BaseHelper resolve real loggers on the server while its own import graph stays browser-pure.
|
|
101
|
-
LoggerResolver.use({ resolver: (opts) => LoggerFactory.getLogger(opts.scopes) });
|
|
102
162
|
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/logger/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,8PAA8P;AAC9P,MAAM,eAAgB,SAAQ,cAAc;IAG1C,YAA6B,KAAa;QACxC,KAAK,EAAE,CAAC;QADmB,UAAK,GAAL,KAAK,CAAQ;IAE1C,CAA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-inversion';\nimport { createRequire } from 'node:module';\nimport { AbstractLogger } from './base/abstract';\nimport { type ILogger, type ILoggerProvider, type TLogLevel } from './common/types';\nimport { LoggerResolver } from './resolver';\n\n/** Stable wrapper the factory hands out; the delegate resolves lazily (first log call or `use()`), never at construction, so no provider loads until needed. Mutual reference with LoggerFactory is by design - hence the `no-use-before-define` disables. */\nclass LoggerDelegator extends AbstractLogger {\n private _delegate?: ILogger;\n\n constructor(private readonly scope: string) {\n super();\n }\n\n repoint(provider: ILoggerProvider): void {\n this._delegate = provider.get(this.scope);\n }\n\n private delegate(): ILogger {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return (this._delegate ??= LoggerFactory.currentProvider().get(this.scope));\n }\n\n debug(message: string, ...args: AnyType[]) {\n this.delegate().debug(message, ...args);\n }\n\n info(message: string, ...args: AnyType[]) {\n this.delegate().info(message, ...args);\n }\n\n warn(message: string, ...args: AnyType[]) {\n this.delegate().warn(message, ...args);\n }\n\n error(message: string, ...args: AnyType[]) {\n this.delegate().error(message, ...args);\n }\n\n emerg(message: string, ...args: AnyType[]) {\n this.delegate().emerg(message, ...args);\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]) {\n this.delegate().log(level, message, ...args);\n }\n\n for(methodName: string): ILogger {\n const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return LoggerFactory.getLogger([childScope]);\n }\n}\n\n/** A bundle can carry two copies of this module - the application's ESM import and core's CJS require. The provider lives in this globalThis slot so `use()` in one copy is seen by the other. */\nconst PROVIDER_SLOT = Symbol.for('ignis:logger-provider');\n\n/** Provider-agnostic acquisition path. Exactly ONE provider is ever loaded - the one registered via `use()`, or the winston default at first unregistered log call. */\nexport class LoggerFactory {\n private static provider?: ILoggerProvider;\n private static cache = new Map<string, LoggerDelegator>();\n\n /** Register the application's provider. Re-points every wrapper issued so far. */\n static use(opts: { provider: ILoggerProvider }): void {\n this.provider = opts.provider;\n Reflect.set(globalThis, PROVIDER_SLOT, opts.provider);\n const cacheValues = this.cache.values();\n for (const wrapper of cacheValues) {\n wrapper.repoint(opts.provider);\n }\n }\n\n static currentProvider(): ILoggerProvider {\n if (!this.provider) {\n this.provider = this.sharedProvider() ?? this.loadDefaultProvider();\n Reflect.set(globalThis, PROVIDER_SLOT, this.provider);\n }\n\n return this.provider;\n }\n\n /** The provider another copy of this module registered, if any. */\n private static sharedProvider(): ILoggerProvider | undefined {\n const shared: ILoggerProvider | undefined = Reflect.get(globalThis, PROVIDER_SLOT);\n return shared;\n }\n\n // winston is an optional peer; compiled binaries must register a provider explicitly because only a class reference carries a provider into a bundle.\n private static loadDefaultProvider(): ILoggerProvider {\n try {\n return createRequire(__filename)('./winston').WinstonLogger;\n } catch (error) {\n throw getError({\n message: [\n '[LoggerFactory] No logger provider is registered and the default (winston) could not be loaded.',\n 'Either install it: `bun add winston winston-transport winston-daily-rotate-file`,',\n 'or register a provider at your entrypoint: `LoggerFactory.use({ provider })` with a class',\n \"from '@venizia/ignis-helpers/winston' or '@venizia/ignis-helpers/pino'.\",\n 'Compiled binaries (bun build --compile) MUST register explicitly.',\n `Cause: ${error instanceof Error ? error.message : String(error)}`,\n ].join(' '),\n });\n }\n }\n\n static getLogger(scopes: string[]): ILogger {\n const scope = scopes.join('-');\n let cached = this.cache.get(scope);\n\n if (!cached) {\n cached = new LoggerDelegator(scope);\n this.cache.set(scope, cached);\n }\n\n return cached;\n }\n}\n\n/** Provider-following facade: always resolves through the registered provider. */\nexport const ApplicationLogger = {\n get: (scope: string): ILogger => LoggerFactory.getLogger([scope]),\n};\n\n// Runs whenever LoggerFactory is imported as a value - which core's Container and every application entrypoint already do. This is what makes BaseHelper resolve real loggers on the server while its own import graph stays browser-pure.\nLoggerResolver.use({ resolver: (opts) => LoggerFactory.getLogger(opts.scopes) });\n"]}
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/logger/factory.ts"],"names":[],"mappings":"A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,MAAM,CAAC,cAAc;QAC3B,MAAM,MAAM,GAAgC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QACnF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,oIAAoI;IACpI,MAAM,CAAC,KAAK;QACV,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAClD,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC/C,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAgB;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjE,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC","sourcesContent":["import { type AnyType } from '@/common/types';\nimport { AbstractLogger } from './base/abstract';\nimport { ConsoleLogger } from './base/console';\nimport { LoggerDebugGate } from './common/debug-gate';\nimport { type ILogger, type ILoggerProvider, LogLevels, type TLogLevel } from './common/types';\n\n/**\n * Stable wrapper the factory hands out. The delegate is resolved on the first log call or by `use()`, never at\n * construction, so no provider is touched until a line is written. The wrapper also applies the factory's level to every\n * provider the same way. Mutual reference with LoggerFactory is by design - hence the `no-use-before-define` disables.\n */\nclass LoggerDelegator extends AbstractLogger {\n private _delegate?: ILogger;\n private _generation = -1;\n\n constructor(private readonly scope: string) {\n super();\n }\n\n /** Takes the new provider's logger for this scope at once: the wrappers of this copy do not wait for their next line. */\n repoint(provider: ILoggerProvider): void {\n this._delegate = provider.get(this.scope);\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n this._generation = LoggerFactory.currentGeneration();\n }\n\n /** The provider's logger for this scope, taken again whenever any copy of the module chose another provider (one integer compare per line). */\n private delegate(): ILogger {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const generation = LoggerFactory.currentGeneration();\n\n if (!this._delegate || this._generation !== generation) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n this._delegate = LoggerFactory.currentProvider().get(this.scope);\n this._generation = generation;\n }\n\n return this._delegate;\n }\n\n /** The level the application set, else the shared debug gate for `debug`: a provider that has no gate of its own is gated the same way. */\n private isEnabled(level: TLogLevel): boolean {\n if (level === LogLevels.DEBUG && !LoggerDebugGate.isOpen()) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const threshold = LoggerFactory.currentLevel();\n return threshold === undefined || LogLevels.isEnabled({ level, threshold });\n }\n\n /** The one place a level method passes its line to the provider, after the one level check. */\n private forward(opts: {\n method: 'debug' | 'info' | 'warn' | 'error' | 'emerg';\n message: string;\n args: AnyType[];\n }): void {\n const { method, message, args } = opts;\n\n if (this.isEnabled(method)) {\n this.delegate()[method](message, ...args);\n }\n }\n\n debug(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.DEBUG, message, args });\n }\n\n info(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.INFO, message, args });\n }\n\n warn(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.WARN, message, args });\n }\n\n error(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.ERROR, message, args });\n }\n\n emerg(message: string, ...args: AnyType[]) {\n this.forward({ method: LogLevels.EMERG, message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: AnyType[]) {\n if (this.isEnabled(level)) {\n this.delegate().log(level, message, ...args);\n }\n }\n\n for(methodName: string): ILogger {\n const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return LoggerFactory.getLogger([childScope]);\n }\n}\n\n/** A bundle can carry two copies of this module - the application's ESM import and core's CJS require. The chosen provider, the level and a counter of choices live in these globalThis slots so `use()` in one copy is seen, on the next line, by the loggers of the other. */\nconst PROVIDER_SLOT = Symbol.for('ignis:logger-provider');\nconst LEVEL_SLOT = Symbol.for('ignis:logger-level');\nconst GENERATION_SLOT = Symbol.for('ignis:logger-generation');\n\n/**\n * The one way to get a logger, and the same everywhere: the server, a script and a browser. It names no provider: the\n * default is the console (`ConsoleLogger`), and an application chooses another with `use()`. It imports nothing from\n * node, so it is part of the browser-pure `core` entry.\n */\nexport class LoggerFactory {\n private static cache = new Map<string, LoggerDelegator>();\n\n /**\n * Choose the application's provider and/or the level. A provider re-points every wrapper issued so far. The level\n * (a `LogLevels` value the application passes) is applied by the wrapper to every provider alike, and it also\n * decides whether `debug` lines are written at all: `debug` turns the gate on, anything above it turns it off,\n * whatever the environment says. A level that is not a `LogLevels` value (a typo, an uppercase name from the\n * environment) is ignored: it must never open debug.\n */\n static use(opts: { provider?: ILoggerProvider; level?: TLogLevel }): void {\n const { provider, level } = opts;\n\n if (level !== undefined && LogLevels.isValid(level)) {\n Reflect.set(globalThis, LEVEL_SLOT, level);\n LoggerDebugGate.force({\n isOpen: LogLevels.isEnabled({ level: LogLevels.DEBUG, threshold: level }),\n });\n }\n\n if (provider === undefined) {\n return;\n }\n\n Reflect.set(globalThis, PROVIDER_SLOT, provider);\n this.bumpGeneration();\n for (const wrapper of this.cache.values()) {\n wrapper.repoint(provider);\n }\n }\n\n /** Choose `provider` only when the application has not chosen one: a framework's startup default, never an override. */\n static useUnlessChosen(opts: { provider: ILoggerProvider }): void {\n if (!this.isChosen()) {\n this.use({ provider: opts.provider });\n }\n }\n\n /** Whether an application (or a framework default through `useUnlessChosen`) has chosen a provider. */\n static isChosen(): boolean {\n return this.sharedProvider() !== undefined;\n }\n\n /** The slot is the only record of the choice, so a `use()` or a `reset()` in any copy of the module is seen by all. */\n static currentProvider(): ILoggerProvider {\n return this.sharedProvider() ?? ConsoleLogger;\n }\n\n /** Moves whenever a provider is chosen or reset, in any copy: a wrapper that cached its logger takes it again. */\n static currentGeneration(): number {\n const generation: number | undefined = Reflect.get(globalThis, GENERATION_SLOT);\n return generation ?? 0;\n }\n\n private static bumpGeneration(): void {\n Reflect.set(globalThis, GENERATION_SLOT, this.currentGeneration() + 1);\n }\n\n /** The level the application set, or `undefined`: then every provider applies its own gate. */\n static currentLevel(): TLogLevel | undefined {\n const level: TLogLevel | undefined = Reflect.get(globalThis, LEVEL_SLOT);\n return level;\n }\n\n /** The provider chosen by any copy of this module, if any. */\n private static sharedProvider(): ILoggerProvider | undefined {\n const shared: ILoggerProvider | undefined = Reflect.get(globalThis, PROVIDER_SLOT);\n return shared;\n }\n\n /** Back to the default provider and no level, and every wrapper takes the console again: for a test, or a host that starts over. */\n static reset(): void {\n Reflect.deleteProperty(globalThis, PROVIDER_SLOT);\n Reflect.deleteProperty(globalThis, LEVEL_SLOT);\n LoggerDebugGate.force({ isOpen: undefined });\n this.bumpGeneration();\n for (const wrapper of this.cache.values()) {\n wrapper.repoint(ConsoleLogger);\n }\n }\n\n static getLogger(scopes: string[]): ILogger {\n const scope = scopes.filter((part) => part.length > 0).join('-');\n let cached = this.cache.get(scope);\n\n if (!cached) {\n cached = new LoggerDelegator(scope);\n this.cache.set(scope, cached);\n }\n\n return cached;\n }\n}\n"]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
export declare class LogFormatUtility {
|
|
3
|
+
private static resolveDepth;
|
|
4
|
+
private static buildInspectOptions;
|
|
5
|
+
/** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */
|
|
6
|
+
static formatMessage(opts: {
|
|
7
|
+
message: string;
|
|
8
|
+
args: Array<unknown>;
|
|
9
|
+
inspectOptions?: util.InspectOptions;
|
|
10
|
+
}): string;
|
|
11
|
+
}
|
|
8
12
|
//# sourceMappingURL=deep-splat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-splat.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"deep-splat.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,YAAY;IAkB3B,OAAO,CAAC,MAAM,CAAC,mBAAmB;IASlC,2TAA2T;IAC3T,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE;QACzB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC;KACtC,GAAG,MAAM;CAgEX"}
|
|
@@ -1,71 +1,82 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedactUtility } from '../../../common/redact.js';
|
|
2
2
|
import util from 'node:util';
|
|
3
3
|
import { ErrorPrettier } from './error-prettier.js';
|
|
4
4
|
/** The placeholders `util.format` understands. `%%` is an escape, not a placeholder. */
|
|
5
5
|
const PLACEHOLDER_PATTERN = /%[sjdifoOc%]/g;
|
|
6
6
|
/** How deep an object is inspected before it collapses to `[Object]`: Node's default of 2 hides nested data (e.g. wrapped `cause`), 5 reaches it while staying bounded. `APP_ENV_LOGGER_INSPECT_DEPTH` overrides with a NON-NEGATIVE number - no unlimited setting. */
|
|
7
7
|
const DEFAULT_INSPECT_DEPTH = 5;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const parsed = Number.parseInt(configured, 10);
|
|
15
|
-
// A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as "unlimited".
|
|
16
|
-
if (Number.isNaN(parsed) || parsed < 0) {
|
|
17
|
-
return DEFAULT_INSPECT_DEPTH;
|
|
18
|
-
}
|
|
19
|
-
return parsed;
|
|
20
|
-
};
|
|
21
|
-
const buildInspectOptions = () => {
|
|
22
|
-
return {
|
|
23
|
-
depth: resolveDepth(),
|
|
24
|
-
maxArrayLength: null,
|
|
25
|
-
maxStringLength: null,
|
|
26
|
-
breakLength: Infinity,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
/** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */
|
|
30
|
-
export const formatLogMessage = (opts) => {
|
|
31
|
-
const { message, args, inspectOptions = buildInspectOptions() } = opts;
|
|
32
|
-
const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter((token) => token !== '%%');
|
|
33
|
-
const widened = args.map((arg, index) => {
|
|
34
|
-
const placeholder = placeholders[index];
|
|
35
|
-
const isInspectable = typeof arg === 'object' && arg !== null;
|
|
36
|
-
if (!isInspectable) {
|
|
37
|
-
return arg;
|
|
38
|
-
}
|
|
39
|
-
// `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.
|
|
40
|
-
if (placeholder === '%j') {
|
|
41
|
-
return toJsonSafe({ value: arg, depth: inspectOptions.depth ?? resolveDepth() });
|
|
42
|
-
}
|
|
43
|
-
// `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but
|
|
44
|
-
// left as objects, so `util.formatWithOptions` still renders them the way that placeholder
|
|
45
|
-
// means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string
|
|
46
|
-
// instead of an object. Only the redaction is added; the rendering is unchanged.
|
|
47
|
-
//
|
|
48
|
-
// Before this, `logger.info('login failed', { password })` printed the password verbatim: the
|
|
49
|
-
// redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.
|
|
50
|
-
//
|
|
51
|
-
// Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep
|
|
52
|
-
// graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a
|
|
53
|
-
// call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.
|
|
54
|
-
if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {
|
|
55
|
-
return redactSecrets(arg, undefined, (inspectOptions.depth ?? resolveDepth()) + 2);
|
|
8
|
+
export class LogFormatUtility {
|
|
9
|
+
static resolveDepth() {
|
|
10
|
+
const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;
|
|
11
|
+
// Not `ParseUtility.toInt()`: it answers 0 for an ABSENT value, which would silently mean "depth 0" - the one setting that hides everything.
|
|
12
|
+
if (configured === undefined || configured.trim() === '') {
|
|
13
|
+
return DEFAULT_INSPECT_DEPTH;
|
|
56
14
|
}
|
|
57
|
-
|
|
58
|
-
|
|
15
|
+
const parsed = Number.parseInt(configured, 10);
|
|
16
|
+
// A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as "unlimited".
|
|
17
|
+
if (Number.isNaN(parsed) || parsed < 0) {
|
|
18
|
+
return DEFAULT_INSPECT_DEPTH;
|
|
59
19
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
20
|
+
return parsed;
|
|
21
|
+
}
|
|
22
|
+
static buildInspectOptions() {
|
|
23
|
+
return {
|
|
24
|
+
depth: LogFormatUtility.resolveDepth(),
|
|
25
|
+
maxArrayLength: null,
|
|
26
|
+
maxStringLength: null,
|
|
27
|
+
breakLength: Infinity,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */
|
|
31
|
+
static formatMessage(opts) {
|
|
32
|
+
const { message, args, inspectOptions = LogFormatUtility.buildInspectOptions() } = opts;
|
|
33
|
+
const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter((token) => token !== '%%');
|
|
34
|
+
const widened = args.map((arg, index) => {
|
|
35
|
+
const placeholder = placeholders[index];
|
|
36
|
+
const isInspectable = typeof arg === 'object' && arg !== null;
|
|
37
|
+
if (!isInspectable) {
|
|
38
|
+
return arg;
|
|
39
|
+
}
|
|
40
|
+
// `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.
|
|
41
|
+
if (placeholder === '%j') {
|
|
42
|
+
return RedactUtility.toJsonSafe({
|
|
43
|
+
value: arg,
|
|
44
|
+
depth: inspectOptions.depth ?? LogFormatUtility.resolveDepth(),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but
|
|
48
|
+
// left as objects, so `util.formatWithOptions` still renders them the way that placeholder
|
|
49
|
+
// means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string
|
|
50
|
+
// instead of an object. Only the redaction is added; the rendering is unchanged.
|
|
51
|
+
//
|
|
52
|
+
// Before this, `logger.info('login failed', { password })` printed the password verbatim: the
|
|
53
|
+
// redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.
|
|
54
|
+
//
|
|
55
|
+
// Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep
|
|
56
|
+
// graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a
|
|
57
|
+
// call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.
|
|
58
|
+
if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {
|
|
59
|
+
return RedactUtility.redactSecrets({
|
|
60
|
+
value: arg,
|
|
61
|
+
depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (placeholder !== '%s') {
|
|
65
|
+
return arg;
|
|
66
|
+
}
|
|
67
|
+
// Inspecting an Error dumps every own property - a `jose` failure carries the whole JWT payload, a driver failure the whole query. Project it instead, onto its own line so it never trails off the end of the caller's sentence.
|
|
68
|
+
if (arg instanceof Error) {
|
|
69
|
+
return `\n${ErrorPrettier.format({ error: arg, inspectOptions })}`;
|
|
70
|
+
}
|
|
71
|
+
// Bounded to just past what `util.inspect` will actually render. `+2`, not `+1`: at exactly
|
|
72
|
+
// `depth + 1` the redactor replaces the last level with a string, and inspect then prints a
|
|
73
|
+
// QUOTED `'[Object]'` instead of its own bare `[Object]`.
|
|
74
|
+
return util.inspect(RedactUtility.redactSecrets({
|
|
75
|
+
value: arg,
|
|
76
|
+
depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,
|
|
77
|
+
}), inspectOptions);
|
|
78
|
+
});
|
|
79
|
+
return util.formatWithOptions(inspectOptions, message, ...widened);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
71
82
|
//# sourceMappingURL=deep-splat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-splat.js","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"deep-splat.js","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,wFAAwF;AACxF,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C,uQAAuQ;AACvQ,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAC,YAAY;QACzB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;QAE5D,6IAA6I;QAC7I,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAE/C,mJAAmJ;QACnJ,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACvC,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,MAAM,CAAC,mBAAmB;QAChC,OAAO;YACL,KAAK,EAAE,gBAAgB,CAAC,YAAY,EAAE;YACtC,cAAc,EAAE,IAAI;YACpB,eAAe,EAAE,IAAI;YACrB,W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IAAI,gBAAgB,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC;iBACrE,CAAC,CAAC;YACL,CAAC;YAED,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;gBACzB,OAAO,GAAG,CAAC;YACb,CAAC;YAED,kOAAkO;YAClO,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;gBACzB,OAAO,KAAK,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;YACrE,CAAC;YAED,4FAA4F;YAC5F,4FAA4F;YAC5F,0DAA0D;YAC1D,OAAO,IAAI,CAAC,OAAO,CACjB,aAAa,CAAC,aAAa,CAAC;gBAC1B,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,CAAC,cAAc,CAAC,KAAK,IAAI,gBAAgB,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC;aACrE,CAAC,EACF,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["import { RedactUtility } from '@/common/redact';\nimport util from 'node:util';\nimport { ErrorPrettier } from './error-prettier';\n\n/** The placeholders `util.format` understands. `%%` is an escape, not a placeholder. */\nconst PLACEHOLDER_PATTERN = /%[sjdifoOc%]/g;\n\n/** How deep an object is inspected before it collapses to `[Object]`: Node's default of 2 hides nested data (e.g. wrapped `cause`), 5 reaches it while staying bounded. `APP_ENV_LOGGER_INSPECT_DEPTH` overrides with a NON-NEGATIVE number - no unlimited setting. */\nconst DEFAULT_INSPECT_DEPTH = 5;\n\nexport class LogFormatUtility {\n private static resolveDepth(): number {\n const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;\n\n // Not `ParseUtility.toInt()`: it answers 0 for an ABSENT value, which would silently mean \"depth 0\" - the one setting that hides everything.\n if (configured === undefined || configured.trim() === '') {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n const parsed = Number.parseInt(configured, 10);\n\n // A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as \"unlimited\".\n if (Number.isNaN(parsed) || parsed < 0) {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n return parsed;\n }\n\n private static buildInspectOptions(): util.InspectOptions {\n return {\n depth: LogFormatUtility.resolveDepth(),\n maxArrayLength: null,\n maxStringLength: null,\n breakLength: Infinity,\n };\n }\n\n /** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */\n static formatMessage(opts: {\n message: string;\n args: Array<unknown>;\n inspectOptions?: util.InspectOptions;\n }): string {\n const { message, args, inspectOptions = LogFormatUtility.buildInspectOptions() } = opts;\n\n const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter(\n (token) => token !== '%%',\n );\n\n const widened = args.map((arg, index) => {\n const placeholder = placeholders[index];\n const isInspectable = typeof arg === 'object' && arg !== null;\n\n if (!isInspectable) {\n return arg;\n }\n\n // `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.\n if (placeholder === '%j') {\n return RedactUtility.toJsonSafe({\n value: arg,\n depth: inspectOptions.depth ?? LogFormatUtility.resolveDepth(),\n });\n }\n\n // `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but\n // left as objects, so `util.formatWithOptions` still renders them the way that placeholder\n // means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string\n // instead of an object. Only the redaction is added; the rendering is unchanged.\n //\n // Before this, `logger.info('login failed', { password })` printed the password verbatim: the\n // redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.\n //\n // Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep\n // graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a\n // call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.\n if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {\n return RedactUtility.redactSecrets({\n value: arg,\n depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,\n });\n }\n\n if (placeholder !== '%s') {\n return arg;\n }\n\n // Inspecting an Error dumps every own property - a `jose` failure carries the whole JWT payload, a driver failure the whole query. Project it instead, onto its own line so it never trails off the end of the caller's sentence.\n if (arg instanceof Error) {\n return `\\n${ErrorPrettier.format({ error: arg, inspectOptions })}`;\n }\n\n // Bounded to just past what `util.inspect` will actually render. `+2`, not `+1`: at exactly\n // `depth + 1` the redactor replaces the last level with a string, and inspect then prints a\n // QUOTED `'[Object]'` instead of its own bare `[Object]`.\n return util.inspect(\n RedactUtility.redactSecrets({\n value: arg,\n depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,\n }),\n inspectOptions,\n );\n });\n\n return util.formatWithOptions(inspectOptions, message, ...widened);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-prettier.d.ts","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/error-prettier.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE9D,0GAA0G;AAC1G,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,kIAAkI;IAClI,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,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@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedactUtility } from '../../../common/redact.js';
|
|
2
2
|
import { MessageCode } from '../../error/index.js';
|
|
3
3
|
import util from 'node:util';
|
|
4
4
|
import { LoggerFormats } from '../common/index.js';
|
|
@@ -173,7 +173,9 @@ export class ErrorPrettier {
|
|
|
173
173
|
}
|
|
174
174
|
// Nothing recognizable: inspect it (redacted) so an unmodelled shape still reaches the log.
|
|
175
175
|
if (Object.keys(summary).length === 0) {
|
|
176
|
-
return {
|
|
176
|
+
return {
|
|
177
|
+
message: util.inspect(RedactUtility.redactSecrets({ value }), this.INSPECT_OPTIONS),
|
|
178
|
+
};
|
|
177
179
|
}
|
|
178
180
|
return summary;
|
|
179
181
|
}
|
|
@@ -238,7 +240,7 @@ export class ErrorPrettier {
|
|
|
238
240
|
payload.message = summary.message;
|
|
239
241
|
}
|
|
240
242
|
if (summary.args !== undefined) {
|
|
241
|
-
payload.args = redactSecrets(summary.args);
|
|
243
|
+
payload.args = RedactUtility.redactSecrets({ value: summary.args });
|
|
242
244
|
}
|
|
243
245
|
// An ApplicationError has no own `code` and a driver error has no `normalized`, so one field never hides the other.
|
|
244
246
|
const code = messageCode !== undefined && messageCode !== ''
|
|
@@ -258,7 +260,7 @@ export class ErrorPrettier {
|
|
|
258
260
|
}
|
|
259
261
|
const context = extra ?? summary.extra;
|
|
260
262
|
if (context !== undefined && Object.keys(context).length > 0) {
|
|
261
|
-
payload.extra = redactSecrets(context);
|
|
263
|
+
payload.extra = RedactUtility.redactSecrets({ value: context });
|
|
262
264
|
}
|
|
263
265
|
if (summary.cause !== undefined) {
|
|
264
266
|
payload.cause = summary.cause;
|
|
@@ -281,7 +283,7 @@ export class ErrorPrettier {
|
|
|
281
283
|
}
|
|
282
284
|
// Straight after the message: the reader is looking at `%{field}` and needs the value now, not below the stack.
|
|
283
285
|
if (summary.args !== undefined) {
|
|
284
|
-
lines.push(`args: ${util.inspect(redactSecrets(summary.args), inspectOptions)}`);
|
|
286
|
+
lines.push(`args: ${util.inspect(RedactUtility.redactSecrets({ value: summary.args }), inspectOptions)}`);
|
|
285
287
|
}
|
|
286
288
|
this.pushAggregatedErrors({ node: summary, lines });
|
|
287
289
|
let cause = summary.cause;
|
|
@@ -309,7 +311,7 @@ export class ErrorPrettier {
|
|
|
309
311
|
// An explicit `extra` wins; otherwise fall back to the one the error carries itself.
|
|
310
312
|
const context = extra ?? summary.extra;
|
|
311
313
|
if (context !== undefined && Object.keys(context).length > 0) {
|
|
312
|
-
lines.push(`extra: ${util.inspect(redactSecrets(context), inspectOptions)}`);
|
|
314
|
+
lines.push(`extra: ${util.inspect(RedactUtility.redactSecrets({ value: context }), inspectOptions)}`);
|
|
313
315
|
}
|
|
314
316
|
if (summary.stack !== undefined) {
|
|
315
317
|
lines.push(`stack:\n${summary.stack}`);
|