@depup/nestjs__common 11.1.16-depup.1
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 +22 -0
- package/PACKAGE.md +1 -0
- package/Readme.md +31 -0
- package/changes.json +10 -0
- package/constants.d.ts +42 -0
- package/constants.js +44 -0
- package/decorators/core/apply-decorators.d.ts +10 -0
- package/decorators/core/apply-decorators.js +23 -0
- package/decorators/core/bind.decorator.d.ts +11 -0
- package/decorators/core/bind.decorator.js +19 -0
- package/decorators/core/catch.decorator.d.ts +19 -0
- package/decorators/core/catch.decorator.js +27 -0
- package/decorators/core/controller.decorator.d.ts +102 -0
- package/decorators/core/controller.decorator.js +61 -0
- package/decorators/core/dependencies.decorator.d.ts +7 -0
- package/decorators/core/dependencies.decorator.js +23 -0
- package/decorators/core/exception-filters.decorator.d.ts +23 -0
- package/decorators/core/exception-filters.decorator.js +43 -0
- package/decorators/core/index.d.ts +14 -0
- package/decorators/core/index.js +17 -0
- package/decorators/core/inject.decorator.d.ts +31 -0
- package/decorators/core/inject.decorator.js +53 -0
- package/decorators/core/injectable.decorator.d.ts +43 -0
- package/decorators/core/injectable.decorator.js +50 -0
- package/decorators/core/optional.decorator.d.ts +14 -0
- package/decorators/core/optional.decorator.js +29 -0
- package/decorators/core/set-metadata.decorator.d.ts +20 -0
- package/decorators/core/set-metadata.decorator.js +32 -0
- package/decorators/core/use-guards.decorator.d.ts +23 -0
- package/decorators/core/use-guards.decorator.js +41 -0
- package/decorators/core/use-interceptors.decorator.d.ts +23 -0
- package/decorators/core/use-interceptors.decorator.js +42 -0
- package/decorators/core/use-pipes.decorator.d.ts +23 -0
- package/decorators/core/use-pipes.decorator.js +40 -0
- package/decorators/core/version.decorator.d.ts +7 -0
- package/decorators/core/version.decorator.js +19 -0
- package/decorators/http/create-route-param-metadata.decorator.d.ts +13 -0
- package/decorators/http/create-route-param-metadata.decorator.js +32 -0
- package/decorators/http/header.decorator.d.ts +15 -0
- package/decorators/http/header.decorator.js +25 -0
- package/decorators/http/http-code.decorator.d.ts +11 -0
- package/decorators/http/http-code.decorator.js +20 -0
- package/decorators/http/index.d.ts +8 -0
- package/decorators/http/index.js +11 -0
- package/decorators/http/redirect.decorator.d.ts +6 -0
- package/decorators/http/redirect.decorator.js +15 -0
- package/decorators/http/render.decorator.d.ts +12 -0
- package/decorators/http/render.decorator.js +21 -0
- package/decorators/http/request-mapping.decorator.d.ts +134 -0
- package/decorators/http/request-mapping.decorator.js +154 -0
- package/decorators/http/route-params.decorator.d.ts +445 -0
- package/decorators/http/route-params.decorator.js +265 -0
- package/decorators/http/sse.decorator.d.ts +10 -0
- package/decorators/http/sse.decorator.js +21 -0
- package/decorators/index.d.ts +3 -0
- package/decorators/index.js +6 -0
- package/decorators/modules/global.decorator.d.ts +12 -0
- package/decorators/modules/global.decorator.js +20 -0
- package/decorators/modules/index.d.ts +2 -0
- package/decorators/modules/index.js +5 -0
- package/decorators/modules/module.decorator.d.ts +16 -0
- package/decorators/modules/module.decorator.js +29 -0
- package/enums/http-status.enum.d.ts +60 -0
- package/enums/http-status.enum.js +64 -0
- package/enums/index.d.ts +4 -0
- package/enums/index.js +7 -0
- package/enums/request-method.enum.d.ts +18 -0
- package/enums/request-method.enum.js +22 -0
- package/enums/route-paramtypes.enum.d.ts +16 -0
- package/enums/route-paramtypes.enum.js +20 -0
- package/enums/shutdown-signal.enum.d.ts +16 -0
- package/enums/shutdown-signal.enum.js +20 -0
- package/enums/version-type.enum.d.ts +9 -0
- package/enums/version-type.enum.js +13 -0
- package/exceptions/bad-gateway.exception.d.ts +35 -0
- package/exceptions/bad-gateway.exception.js +43 -0
- package/exceptions/bad-request.exception.d.ts +35 -0
- package/exceptions/bad-request.exception.js +43 -0
- package/exceptions/conflict.exception.d.ts +35 -0
- package/exceptions/conflict.exception.js +43 -0
- package/exceptions/forbidden.exception.d.ts +35 -0
- package/exceptions/forbidden.exception.js +43 -0
- package/exceptions/gateway-timeout.exception.d.ts +35 -0
- package/exceptions/gateway-timeout.exception.js +43 -0
- package/exceptions/gone.exception.d.ts +35 -0
- package/exceptions/gone.exception.js +43 -0
- package/exceptions/http-version-not-supported.exception.d.ts +35 -0
- package/exceptions/http-version-not-supported.exception.js +43 -0
- package/exceptions/http.exception.d.ts +85 -0
- package/exceptions/http.exception.js +133 -0
- package/exceptions/im-a-teapot.exception.d.ts +38 -0
- package/exceptions/im-a-teapot.exception.js +46 -0
- package/exceptions/index.d.ts +23 -0
- package/exceptions/index.js +26 -0
- package/exceptions/internal-server-error.exception.d.ts +35 -0
- package/exceptions/internal-server-error.exception.js +43 -0
- package/exceptions/intrinsic.exception.d.ts +8 -0
- package/exceptions/intrinsic.exception.js +12 -0
- package/exceptions/method-not-allowed.exception.d.ts +35 -0
- package/exceptions/method-not-allowed.exception.js +43 -0
- package/exceptions/misdirected.exception.d.ts +35 -0
- package/exceptions/misdirected.exception.js +43 -0
- package/exceptions/not-acceptable.exception.d.ts +35 -0
- package/exceptions/not-acceptable.exception.js +43 -0
- package/exceptions/not-found.exception.d.ts +35 -0
- package/exceptions/not-found.exception.js +43 -0
- package/exceptions/not-implemented.exception.d.ts +35 -0
- package/exceptions/not-implemented.exception.js +43 -0
- package/exceptions/payload-too-large.exception.d.ts +35 -0
- package/exceptions/payload-too-large.exception.js +43 -0
- package/exceptions/precondition-failed.exception.d.ts +35 -0
- package/exceptions/precondition-failed.exception.js +43 -0
- package/exceptions/request-timeout.exception.d.ts +35 -0
- package/exceptions/request-timeout.exception.js +43 -0
- package/exceptions/service-unavailable.exception.d.ts +35 -0
- package/exceptions/service-unavailable.exception.js +43 -0
- package/exceptions/unauthorized.exception.d.ts +35 -0
- package/exceptions/unauthorized.exception.js +43 -0
- package/exceptions/unprocessable-entity.exception.d.ts +35 -0
- package/exceptions/unprocessable-entity.exception.js +43 -0
- package/exceptions/unsupported-media-type.exception.d.ts +35 -0
- package/exceptions/unsupported-media-type.exception.js +43 -0
- package/file-stream/index.d.ts +1 -0
- package/file-stream/index.js +4 -0
- package/file-stream/interfaces/index.d.ts +2 -0
- package/file-stream/interfaces/index.js +5 -0
- package/file-stream/interfaces/streamable-handler-response.interface.d.ts +12 -0
- package/file-stream/interfaces/streamable-handler-response.interface.js +2 -0
- package/file-stream/interfaces/streamable-options.interface.d.ts +22 -0
- package/file-stream/interfaces/streamable-options.interface.js +2 -0
- package/file-stream/streamable-file.d.ts +27 -0
- package/file-stream/streamable-file.js +68 -0
- package/index.d.ts +11 -0
- package/index.js +23 -0
- package/interfaces/abstract.interface.d.ts +3 -0
- package/interfaces/abstract.interface.js +2 -0
- package/interfaces/controllers/controller-metadata.interface.d.ts +3 -0
- package/interfaces/controllers/controller-metadata.interface.js +2 -0
- package/interfaces/controllers/controller.interface.d.ts +1 -0
- package/interfaces/controllers/controller.interface.js +2 -0
- package/interfaces/controllers/index.d.ts +2 -0
- package/interfaces/controllers/index.js +5 -0
- package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +6 -0
- package/interfaces/exceptions/exception-filter-metadata.interface.js +2 -0
- package/interfaces/exceptions/exception-filter.interface.d.ts +18 -0
- package/interfaces/exceptions/exception-filter.interface.js +2 -0
- package/interfaces/exceptions/index.d.ts +5 -0
- package/interfaces/exceptions/index.js +8 -0
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +6 -0
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +2 -0
- package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +19 -0
- package/interfaces/exceptions/rpc-exception-filter.interface.js +2 -0
- package/interfaces/exceptions/ws-exception-filter.interface.d.ts +18 -0
- package/interfaces/exceptions/ws-exception-filter.interface.js +2 -0
- package/interfaces/external/class-transform-options.interface.d.ts +65 -0
- package/interfaces/external/class-transform-options.interface.js +2 -0
- package/interfaces/external/cors-options.interface.d.ts +58 -0
- package/interfaces/external/cors-options.interface.js +2 -0
- package/interfaces/external/https-options.interface.d.ts +105 -0
- package/interfaces/external/https-options.interface.js +2 -0
- package/interfaces/external/transformer-package.interface.d.ts +6 -0
- package/interfaces/external/transformer-package.interface.js +2 -0
- package/interfaces/external/validation-error.interface.d.ts +42 -0
- package/interfaces/external/validation-error.interface.js +2 -0
- package/interfaces/external/validator-options.interface.d.ts +76 -0
- package/interfaces/external/validator-options.interface.js +2 -0
- package/interfaces/external/validator-package.interface.d.ts +5 -0
- package/interfaces/external/validator-package.interface.js +2 -0
- package/interfaces/features/arguments-host.interface.d.ts +88 -0
- package/interfaces/features/arguments-host.interface.js +2 -0
- package/interfaces/features/can-activate.interface.d.ts +22 -0
- package/interfaces/features/can-activate.interface.js +2 -0
- package/interfaces/features/custom-route-param-factory.interface.d.ts +5 -0
- package/interfaces/features/custom-route-param-factory.interface.js +2 -0
- package/interfaces/features/execution-context.interface.d.ts +20 -0
- package/interfaces/features/execution-context.interface.js +2 -0
- package/interfaces/features/nest-interceptor.interface.d.ts +34 -0
- package/interfaces/features/nest-interceptor.interface.js +2 -0
- package/interfaces/features/paramtype.interface.d.ts +4 -0
- package/interfaces/features/paramtype.interface.js +2 -0
- package/interfaces/features/pipe-transform.interface.d.ts +42 -0
- package/interfaces/features/pipe-transform.interface.js +2 -0
- package/interfaces/global-prefix-options.interface.d.ts +7 -0
- package/interfaces/global-prefix-options.interface.js +2 -0
- package/interfaces/hooks/before-application-shutdown.interface.d.ts +3 -0
- package/interfaces/hooks/before-application-shutdown.interface.js +2 -0
- package/interfaces/hooks/index.d.ts +5 -0
- package/interfaces/hooks/index.js +8 -0
- package/interfaces/hooks/on-application-bootstrap.interface.d.ts +11 -0
- package/interfaces/hooks/on-application-bootstrap.interface.js +2 -0
- package/interfaces/hooks/on-application-shutdown.interface.d.ts +11 -0
- package/interfaces/hooks/on-application-shutdown.interface.js +2 -0
- package/interfaces/hooks/on-destroy.interface.d.ts +12 -0
- package/interfaces/hooks/on-destroy.interface.js +2 -0
- package/interfaces/hooks/on-init.interface.d.ts +10 -0
- package/interfaces/hooks/on-init.interface.js +2 -0
- package/interfaces/http/http-exception-body.interface.d.ts +6 -0
- package/interfaces/http/http-exception-body.interface.js +2 -0
- package/interfaces/http/http-redirect-response.interface.d.ts +5 -0
- package/interfaces/http/http-redirect-response.interface.js +2 -0
- package/interfaces/http/http-server.interface.d.ts +70 -0
- package/interfaces/http/http-server.interface.js +2 -0
- package/interfaces/http/index.d.ts +5 -0
- package/interfaces/http/index.js +8 -0
- package/interfaces/http/message-event.interface.d.ts +6 -0
- package/interfaces/http/message-event.interface.js +2 -0
- package/interfaces/http/raw-body-request.interface.d.ts +6 -0
- package/interfaces/http/raw-body-request.interface.js +2 -0
- package/interfaces/index.d.ts +30 -0
- package/interfaces/index.js +33 -0
- package/interfaces/injectable.interface.d.ts +1 -0
- package/interfaces/injectable.interface.js +2 -0
- package/interfaces/microservices/nest-hybrid-application-options.interface.d.ts +7 -0
- package/interfaces/microservices/nest-hybrid-application-options.interface.js +2 -0
- package/interfaces/microservices/nest-microservice-options.interface.d.ts +5 -0
- package/interfaces/microservices/nest-microservice-options.interface.js +2 -0
- package/interfaces/middleware/index.d.ts +4 -0
- package/interfaces/middleware/index.js +7 -0
- package/interfaces/middleware/middleware-config-proxy.interface.d.ts +24 -0
- package/interfaces/middleware/middleware-config-proxy.interface.js +2 -0
- package/interfaces/middleware/middleware-configuration.interface.d.ts +12 -0
- package/interfaces/middleware/middleware-configuration.interface.js +2 -0
- package/interfaces/middleware/middleware-consumer.interface.d.ts +18 -0
- package/interfaces/middleware/middleware-consumer.interface.js +2 -0
- package/interfaces/middleware/nest-middleware.interface.d.ts +8 -0
- package/interfaces/middleware/nest-middleware.interface.js +2 -0
- package/interfaces/modules/dynamic-module.interface.d.ts +25 -0
- package/interfaces/modules/dynamic-module.interface.js +2 -0
- package/interfaces/modules/forward-reference.interface.d.ts +3 -0
- package/interfaces/modules/forward-reference.interface.js +2 -0
- package/interfaces/modules/index.d.ts +8 -0
- package/interfaces/modules/index.js +11 -0
- package/interfaces/modules/injection-token.interface.d.ts +6 -0
- package/interfaces/modules/injection-token.interface.js +2 -0
- package/interfaces/modules/introspection-result.interface.d.ts +10 -0
- package/interfaces/modules/introspection-result.interface.js +2 -0
- package/interfaces/modules/module-metadata.interface.d.ts +34 -0
- package/interfaces/modules/module-metadata.interface.js +2 -0
- package/interfaces/modules/nest-module.interface.d.ts +7 -0
- package/interfaces/modules/nest-module.interface.js +2 -0
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +8 -0
- package/interfaces/modules/optional-factory-dependency.interface.js +2 -0
- package/interfaces/modules/provider.interface.d.ts +156 -0
- package/interfaces/modules/provider.interface.js +2 -0
- package/interfaces/nest-application-context-options.interface.d.ts +68 -0
- package/interfaces/nest-application-context-options.interface.js +9 -0
- package/interfaces/nest-application-context.interface.d.ts +139 -0
- package/interfaces/nest-application-context.interface.js +2 -0
- package/interfaces/nest-application-options.interface.d.ts +29 -0
- package/interfaces/nest-application-options.interface.js +2 -0
- package/interfaces/nest-application.interface.d.ts +135 -0
- package/interfaces/nest-application.interface.js +2 -0
- package/interfaces/nest-microservice.interface.d.ts +75 -0
- package/interfaces/nest-microservice.interface.js +2 -0
- package/interfaces/scope-options.interface.d.ts +37 -0
- package/interfaces/scope-options.interface.js +23 -0
- package/interfaces/shutdown-hooks-options.interface.d.ts +21 -0
- package/interfaces/shutdown-hooks-options.interface.js +2 -0
- package/interfaces/type.interface.d.ts +3 -0
- package/interfaces/type.interface.js +2 -0
- package/interfaces/version-options.interface.d.ts +92 -0
- package/interfaces/version-options.interface.js +9 -0
- package/interfaces/websockets/web-socket-adapter.interface.d.ts +19 -0
- package/interfaces/websockets/web-socket-adapter.interface.js +2 -0
- package/module-utils/configurable-module.builder.d.ts +93 -0
- package/module-utils/configurable-module.builder.js +219 -0
- package/module-utils/constants.d.ts +9 -0
- package/module-utils/constants.js +19 -0
- package/module-utils/index.d.ts +2 -0
- package/module-utils/index.js +5 -0
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +42 -0
- package/module-utils/interfaces/configurable-module-async-options.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +13 -0
- package/module-utils/interfaces/configurable-module-cls.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +62 -0
- package/module-utils/interfaces/configurable-module-host.interface.js +2 -0
- package/module-utils/interfaces/index.d.ts +3 -0
- package/module-utils/interfaces/index.js +6 -0
- package/module-utils/utils/generate-options-injection-token.util.d.ts +1 -0
- package/module-utils/utils/generate-options-injection-token.util.js +8 -0
- package/module-utils/utils/get-injection-providers.util.d.ts +8 -0
- package/module-utils/utils/get-injection-providers.util.js +35 -0
- package/module-utils/utils/index.d.ts +2 -0
- package/module-utils/utils/index.js +5 -0
- package/package.json +61 -0
- package/pipes/default-value.pipe.d.ts +13 -0
- package/pipes/default-value.pipe.js +30 -0
- package/pipes/file/file-type.validator.d.ts +62 -0
- package/pipes/file/file-type.validator.js +102 -0
- package/pipes/file/file-validator-context.interface.d.ts +5 -0
- package/pipes/file/file-validator-context.interface.js +2 -0
- package/pipes/file/file-validator.interface.d.ts +21 -0
- package/pipes/file/file-validator.interface.js +15 -0
- package/pipes/file/index.d.ts +6 -0
- package/pipes/file/index.js +9 -0
- package/pipes/file/interfaces/file.interface.d.ts +5 -0
- package/pipes/file/interfaces/file.interface.js +2 -0
- package/pipes/file/interfaces/index.d.ts +1 -0
- package/pipes/file/interfaces/index.js +4 -0
- package/pipes/file/max-file-size.validator.d.ts +44 -0
- package/pipes/file/max-file-size.validator.js +37 -0
- package/pipes/file/parse-file-options.interface.d.ts +15 -0
- package/pipes/file/parse-file-options.interface.js +2 -0
- package/pipes/file/parse-file-pipe.builder.d.ts +15 -0
- package/pipes/file/parse-file-pipe.builder.js +33 -0
- package/pipes/file/parse-file.pipe.d.ts +28 -0
- package/pipes/file/parse-file.pipe.js +76 -0
- package/pipes/index.d.ts +10 -0
- package/pipes/index.js +13 -0
- package/pipes/parse-array.pipe.d.ts +52 -0
- package/pipes/parse-array.pipe.js +148 -0
- package/pipes/parse-bool.pipe.d.ts +55 -0
- package/pipes/parse-bool.pipe.js +67 -0
- package/pipes/parse-date.pipe.d.ts +37 -0
- package/pipes/parse-date.pipe.js +42 -0
- package/pipes/parse-enum.pipe.d.ts +46 -0
- package/pipes/parse-enum.pipe.js +55 -0
- package/pipes/parse-float.pipe.d.ts +49 -0
- package/pipes/parse-float.pipe.js +56 -0
- package/pipes/parse-int.pipe.d.ts +48 -0
- package/pipes/parse-int.pipe.js +57 -0
- package/pipes/parse-uuid.pipe.d.ts +49 -0
- package/pipes/parse-uuid.pipe.js +57 -0
- package/pipes/validation.pipe.d.ts +51 -0
- package/pipes/validation.pipe.js +245 -0
- package/serializer/class-serializer.constants.d.ts +1 -0
- package/serializer/class-serializer.constants.js +4 -0
- package/serializer/class-serializer.interceptor.d.ts +29 -0
- package/serializer/class-serializer.interceptor.js +77 -0
- package/serializer/class-serializer.interfaces.d.ts +8 -0
- package/serializer/class-serializer.interfaces.js +2 -0
- package/serializer/decorators/index.d.ts +1 -0
- package/serializer/decorators/index.js +4 -0
- package/serializer/decorators/serialize-options.decorator.d.ts +5 -0
- package/serializer/decorators/serialize-options.decorator.js +10 -0
- package/serializer/index.d.ts +3 -0
- package/serializer/index.js +6 -0
- package/services/console-logger.service.d.ts +202 -0
- package/services/console-logger.service.js +379 -0
- package/services/index.d.ts +3 -0
- package/services/index.js +6 -0
- package/services/logger.service.d.ts +152 -0
- package/services/logger.service.js +251 -0
- package/services/utils/filter-log-levels.util.d.ts +5 -0
- package/services/utils/filter-log-levels.util.js +23 -0
- package/services/utils/index.d.ts +3 -0
- package/services/utils/index.js +6 -0
- package/services/utils/is-log-level-enabled.util.d.ts +7 -0
- package/services/utils/is-log-level-enabled.util.js +32 -0
- package/services/utils/is-log-level.util.d.ts +5 -0
- package/services/utils/is-log-level.util.js +10 -0
- package/tsconfig.build.json +10 -0
- package/utils/assign-custom-metadata.util.d.ts +4 -0
- package/utils/assign-custom-metadata.util.js +15 -0
- package/utils/cli-colors.util.d.ts +10 -0
- package/utils/cli-colors.util.js +15 -0
- package/utils/extend-metadata.util.d.ts +1 -0
- package/utils/extend-metadata.util.js +8 -0
- package/utils/forward-ref.util.d.ts +5 -0
- package/utils/forward-ref.util.js +10 -0
- package/utils/http-error-by-code.util.d.ts +4 -0
- package/utils/http-error-by-code.util.js +26 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +4 -0
- package/utils/load-package.util.d.ts +1 -0
- package/utils/load-package.util.js +16 -0
- package/utils/merge-with-values.util.d.ts +4 -0
- package/utils/merge-with-values.util.js +18 -0
- package/utils/random-string-generator.util.d.ts +1 -0
- package/utils/random-string-generator.util.js +6 -0
- package/utils/select-exception-filter-metadata.util.d.ts +2 -0
- package/utils/select-exception-filter-metadata.util.js +6 -0
- package/utils/shared.utils.d.ts +13 -0
- package/utils/shared.utils.js +51 -0
- package/utils/validate-each.util.d.ts +8 -0
- package/utils/validate-each.util.js +25 -0
- package/utils/validate-module-keys.util.d.ts +2 -0
- package/utils/validate-module-keys.util.js +22 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { InspectOptions } from 'util';
|
|
2
|
+
import { LoggerService, LogLevel } from './logger.service';
|
|
3
|
+
/**
|
|
4
|
+
* @publicApi
|
|
5
|
+
*/
|
|
6
|
+
export interface ConsoleLoggerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Enabled log levels.
|
|
9
|
+
*/
|
|
10
|
+
logLevels?: LogLevel[];
|
|
11
|
+
/**
|
|
12
|
+
* If enabled, will print timestamp (time difference) between current and previous log message.
|
|
13
|
+
* Note: This option is not used when `json` is enabled.
|
|
14
|
+
*/
|
|
15
|
+
timestamp?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* A prefix to be used for each log message.
|
|
18
|
+
* Note: This option is not used when `json` is enabled.
|
|
19
|
+
*/
|
|
20
|
+
prefix?: string;
|
|
21
|
+
/**
|
|
22
|
+
* If enabled, will print the log message in JSON format.
|
|
23
|
+
*/
|
|
24
|
+
json?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* If enabled, will print the log message in color.
|
|
27
|
+
* Default true if json is disabled, false otherwise
|
|
28
|
+
*/
|
|
29
|
+
colors?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The context of the logger.
|
|
32
|
+
*/
|
|
33
|
+
context?: string;
|
|
34
|
+
/**
|
|
35
|
+
* If enabled, will force the use of console.log/console.error instead of process.stdout/stderr.write.
|
|
36
|
+
* This is useful for test environments like Jest that can buffer console calls.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
forceConsole?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* If enabled, will print the log message in a single line, even if it is an object with multiple properties.
|
|
42
|
+
* If set to a number, the most n inner elements are united on a single line as long as all properties fit into breakLength. Short array elements are also grouped together.
|
|
43
|
+
* Default true when `json` is enabled, false otherwise.
|
|
44
|
+
*/
|
|
45
|
+
compact?: boolean | number;
|
|
46
|
+
/**
|
|
47
|
+
* Specifies the maximum number of Array, TypedArray, Map, Set, WeakMap, and WeakSet elements to include when formatting.
|
|
48
|
+
* Set to null or Infinity to show all elements. Set to 0 or negative to show no elements.
|
|
49
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
50
|
+
* @default 100
|
|
51
|
+
*/
|
|
52
|
+
maxArrayLength?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Specifies the maximum number of characters to include when formatting.
|
|
55
|
+
* Set to null or Infinity to show all elements. Set to 0 or negative to show no characters.
|
|
56
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
57
|
+
* @default 10000.
|
|
58
|
+
*/
|
|
59
|
+
maxStringLength?: number;
|
|
60
|
+
/**
|
|
61
|
+
* If enabled, will sort keys while formatting objects.
|
|
62
|
+
* Can also be a custom sorting function.
|
|
63
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
sorted?: boolean | ((a: string, b: string) => number);
|
|
67
|
+
/**
|
|
68
|
+
* Specifies the number of times to recurse while formatting object.
|
|
69
|
+
* This is useful for inspecting large objects. To recurse up to the maximum call stack size pass Infinity or null.
|
|
70
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
71
|
+
* @default 5
|
|
72
|
+
*/
|
|
73
|
+
depth?: number;
|
|
74
|
+
/**
|
|
75
|
+
* If true, object's non-enumerable symbols and properties are included in the formatted result.
|
|
76
|
+
* WeakMap and WeakSet entries are also included as well as user defined prototype properties
|
|
77
|
+
* @default false
|
|
78
|
+
*/
|
|
79
|
+
showHidden?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The length at which input values are split across multiple lines. Set to Infinity to format the input as a single line (in combination with "compact" set to true).
|
|
82
|
+
* Default Infinity when "compact" is true, 80 otherwise.
|
|
83
|
+
* Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
|
|
84
|
+
*/
|
|
85
|
+
breakLength?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @publicApi
|
|
89
|
+
*/
|
|
90
|
+
export declare class ConsoleLogger implements LoggerService {
|
|
91
|
+
/**
|
|
92
|
+
* The options of the logger.
|
|
93
|
+
*/
|
|
94
|
+
protected options: ConsoleLoggerOptions;
|
|
95
|
+
/**
|
|
96
|
+
* The context of the logger (can be set manually or automatically inferred).
|
|
97
|
+
*/
|
|
98
|
+
protected context?: string;
|
|
99
|
+
/**
|
|
100
|
+
* The original context of the logger (set in the constructor).
|
|
101
|
+
*/
|
|
102
|
+
protected originalContext?: string;
|
|
103
|
+
/**
|
|
104
|
+
* The options used for the "inspect" method.
|
|
105
|
+
*/
|
|
106
|
+
protected inspectOptions: InspectOptions;
|
|
107
|
+
/**
|
|
108
|
+
* The last timestamp at which the log message was printed.
|
|
109
|
+
*/
|
|
110
|
+
protected static lastTimestampAt?: number;
|
|
111
|
+
constructor();
|
|
112
|
+
constructor(context: string);
|
|
113
|
+
constructor(options: ConsoleLoggerOptions);
|
|
114
|
+
constructor(context: string, options: ConsoleLoggerOptions);
|
|
115
|
+
/**
|
|
116
|
+
* Write a 'log' level log, if the configured level allows for it.
|
|
117
|
+
* Prints to `stdout` with newline.
|
|
118
|
+
*/
|
|
119
|
+
log(message: any, context?: string): void;
|
|
120
|
+
log(message: any, ...optionalParams: [...any, string?]): void;
|
|
121
|
+
/**
|
|
122
|
+
* Write an 'error' level log, if the configured level allows for it.
|
|
123
|
+
* Prints to `stderr` with newline.
|
|
124
|
+
*/
|
|
125
|
+
error(message: any, stackOrContext?: string): void;
|
|
126
|
+
error(message: any, stack?: string, context?: string): void;
|
|
127
|
+
error(message: any, ...optionalParams: [...any, string?, string?]): void;
|
|
128
|
+
/**
|
|
129
|
+
* Write a 'warn' level log, if the configured level allows for it.
|
|
130
|
+
* Prints to `stdout` with newline.
|
|
131
|
+
*/
|
|
132
|
+
warn(message: any, context?: string): void;
|
|
133
|
+
warn(message: any, ...optionalParams: [...any, string?]): void;
|
|
134
|
+
/**
|
|
135
|
+
* Write a 'debug' level log, if the configured level allows for it.
|
|
136
|
+
* Prints to `stdout` with newline.
|
|
137
|
+
*/
|
|
138
|
+
debug(message: any, context?: string): void;
|
|
139
|
+
debug(message: any, ...optionalParams: [...any, string?]): void;
|
|
140
|
+
/**
|
|
141
|
+
* Write a 'verbose' level log, if the configured level allows for it.
|
|
142
|
+
* Prints to `stdout` with newline.
|
|
143
|
+
*/
|
|
144
|
+
verbose(message: any, context?: string): void;
|
|
145
|
+
verbose(message: any, ...optionalParams: [...any, string?]): void;
|
|
146
|
+
/**
|
|
147
|
+
* Write a 'fatal' level log, if the configured level allows for it.
|
|
148
|
+
* Prints to `stdout` with newline.
|
|
149
|
+
*/
|
|
150
|
+
fatal(message: any, context?: string): void;
|
|
151
|
+
fatal(message: any, ...optionalParams: [...any, string?]): void;
|
|
152
|
+
/**
|
|
153
|
+
* Set log levels
|
|
154
|
+
* @param levels log levels
|
|
155
|
+
*/
|
|
156
|
+
setLogLevels(levels: LogLevel[]): void;
|
|
157
|
+
/**
|
|
158
|
+
* Set logger context
|
|
159
|
+
* @param context context
|
|
160
|
+
*/
|
|
161
|
+
setContext(context: string): void;
|
|
162
|
+
/**
|
|
163
|
+
* Resets the logger context to the value that was passed in the constructor.
|
|
164
|
+
*/
|
|
165
|
+
resetContext(): void;
|
|
166
|
+
isLevelEnabled(level: LogLevel): boolean;
|
|
167
|
+
protected getTimestamp(): string;
|
|
168
|
+
protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr', errorStack?: unknown): void;
|
|
169
|
+
protected printAsJson(message: unknown, options: {
|
|
170
|
+
context: string;
|
|
171
|
+
logLevel: LogLevel;
|
|
172
|
+
writeStreamType?: 'stdout' | 'stderr';
|
|
173
|
+
errorStack?: unknown;
|
|
174
|
+
}): void;
|
|
175
|
+
protected getJsonLogObject(message: unknown, options: {
|
|
176
|
+
context: string;
|
|
177
|
+
logLevel: LogLevel;
|
|
178
|
+
writeStreamType?: 'stdout' | 'stderr';
|
|
179
|
+
errorStack?: unknown;
|
|
180
|
+
}): {
|
|
181
|
+
level: LogLevel;
|
|
182
|
+
pid: number;
|
|
183
|
+
timestamp: number;
|
|
184
|
+
message: unknown;
|
|
185
|
+
context?: string;
|
|
186
|
+
stack?: unknown;
|
|
187
|
+
};
|
|
188
|
+
protected formatPid(pid: number): string;
|
|
189
|
+
protected formatContext(context: string): string;
|
|
190
|
+
protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
|
|
191
|
+
protected stringifyMessage(message: unknown, logLevel: LogLevel): any;
|
|
192
|
+
protected colorize(message: string, logLevel: LogLevel): string;
|
|
193
|
+
protected printStackTrace(stack: string): void;
|
|
194
|
+
protected updateAndGetTimestampDiff(): string;
|
|
195
|
+
protected formatTimestampDiff(timestampDiff: number): string;
|
|
196
|
+
protected getInspectOptions(): InspectOptions;
|
|
197
|
+
protected stringifyReplacer(key: string, value: unknown): unknown;
|
|
198
|
+
private getContextAndMessagesToPrint;
|
|
199
|
+
private getContextAndStackAndMessagesToPrint;
|
|
200
|
+
private isStackFormat;
|
|
201
|
+
private getColorByLogLevel;
|
|
202
|
+
}
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var ConsoleLogger_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ConsoleLogger = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
const core_1 = require("../decorators/core");
|
|
8
|
+
const cli_colors_util_1 = require("../utils/cli-colors.util");
|
|
9
|
+
const shared_utils_1 = require("../utils/shared.utils");
|
|
10
|
+
const is_log_level_enabled_util_1 = require("./utils/is-log-level-enabled.util");
|
|
11
|
+
const DEFAULT_DEPTH = 5;
|
|
12
|
+
const DEFAULT_LOG_LEVELS = [
|
|
13
|
+
'log',
|
|
14
|
+
'error',
|
|
15
|
+
'warn',
|
|
16
|
+
'debug',
|
|
17
|
+
'verbose',
|
|
18
|
+
'fatal',
|
|
19
|
+
];
|
|
20
|
+
const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
21
|
+
year: 'numeric',
|
|
22
|
+
hour: 'numeric',
|
|
23
|
+
minute: 'numeric',
|
|
24
|
+
second: 'numeric',
|
|
25
|
+
day: '2-digit',
|
|
26
|
+
month: '2-digit',
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* @publicApi
|
|
30
|
+
*/
|
|
31
|
+
let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
32
|
+
constructor(contextOrOptions, options) {
|
|
33
|
+
// eslint-disable-next-line prefer-const
|
|
34
|
+
let [context, opts] = (0, shared_utils_1.isString)(contextOrOptions)
|
|
35
|
+
? [contextOrOptions, options]
|
|
36
|
+
: options
|
|
37
|
+
? [undefined, options]
|
|
38
|
+
: [contextOrOptions?.context, contextOrOptions];
|
|
39
|
+
opts = opts ?? {};
|
|
40
|
+
opts.logLevels ??= DEFAULT_LOG_LEVELS;
|
|
41
|
+
opts.colors ??= opts.colors ?? (opts.json ? false : (0, cli_colors_util_1.isColorAllowed)());
|
|
42
|
+
opts.prefix ??= 'Nest';
|
|
43
|
+
this.options = opts;
|
|
44
|
+
this.inspectOptions = this.getInspectOptions();
|
|
45
|
+
if (context) {
|
|
46
|
+
this.context = context;
|
|
47
|
+
this.originalContext = context;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
log(message, ...optionalParams) {
|
|
51
|
+
if (!this.isLevelEnabled('log')) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
55
|
+
message,
|
|
56
|
+
...optionalParams,
|
|
57
|
+
]);
|
|
58
|
+
this.printMessages(messages, context, 'log');
|
|
59
|
+
}
|
|
60
|
+
error(message, ...optionalParams) {
|
|
61
|
+
if (!this.isLevelEnabled('error')) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const { messages, context, stack } = this.getContextAndStackAndMessagesToPrint([message, ...optionalParams]);
|
|
65
|
+
this.printMessages(messages, context, 'error', 'stderr', stack);
|
|
66
|
+
this.printStackTrace(stack);
|
|
67
|
+
}
|
|
68
|
+
warn(message, ...optionalParams) {
|
|
69
|
+
if (!this.isLevelEnabled('warn')) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
73
|
+
message,
|
|
74
|
+
...optionalParams,
|
|
75
|
+
]);
|
|
76
|
+
this.printMessages(messages, context, 'warn');
|
|
77
|
+
}
|
|
78
|
+
debug(message, ...optionalParams) {
|
|
79
|
+
if (!this.isLevelEnabled('debug')) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
83
|
+
message,
|
|
84
|
+
...optionalParams,
|
|
85
|
+
]);
|
|
86
|
+
this.printMessages(messages, context, 'debug');
|
|
87
|
+
}
|
|
88
|
+
verbose(message, ...optionalParams) {
|
|
89
|
+
if (!this.isLevelEnabled('verbose')) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
93
|
+
message,
|
|
94
|
+
...optionalParams,
|
|
95
|
+
]);
|
|
96
|
+
this.printMessages(messages, context, 'verbose');
|
|
97
|
+
}
|
|
98
|
+
fatal(message, ...optionalParams) {
|
|
99
|
+
if (!this.isLevelEnabled('fatal')) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
103
|
+
message,
|
|
104
|
+
...optionalParams,
|
|
105
|
+
]);
|
|
106
|
+
this.printMessages(messages, context, 'fatal');
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Set log levels
|
|
110
|
+
* @param levels log levels
|
|
111
|
+
*/
|
|
112
|
+
setLogLevels(levels) {
|
|
113
|
+
if (!this.options) {
|
|
114
|
+
this.options = {};
|
|
115
|
+
}
|
|
116
|
+
this.options.logLevels = levels;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Set logger context
|
|
120
|
+
* @param context context
|
|
121
|
+
*/
|
|
122
|
+
setContext(context) {
|
|
123
|
+
this.context = context;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Resets the logger context to the value that was passed in the constructor.
|
|
127
|
+
*/
|
|
128
|
+
resetContext() {
|
|
129
|
+
this.context = this.originalContext;
|
|
130
|
+
}
|
|
131
|
+
isLevelEnabled(level) {
|
|
132
|
+
const logLevels = this.options?.logLevels;
|
|
133
|
+
return (0, is_log_level_enabled_util_1.isLogLevelEnabled)(level, logLevels);
|
|
134
|
+
}
|
|
135
|
+
getTimestamp() {
|
|
136
|
+
return dateTimeFormatter.format(Date.now());
|
|
137
|
+
}
|
|
138
|
+
printMessages(messages, context = '', logLevel = 'log', writeStreamType, errorStack) {
|
|
139
|
+
messages.forEach(message => {
|
|
140
|
+
if (this.options.json) {
|
|
141
|
+
this.printAsJson(message, {
|
|
142
|
+
context,
|
|
143
|
+
logLevel,
|
|
144
|
+
writeStreamType,
|
|
145
|
+
errorStack,
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const pidMessage = this.formatPid(process.pid);
|
|
150
|
+
const contextMessage = this.formatContext(context);
|
|
151
|
+
const timestampDiff = this.updateAndGetTimestampDiff();
|
|
152
|
+
const formattedLogLevel = logLevel.toUpperCase().padStart(7, ' ');
|
|
153
|
+
const formattedMessage = this.formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff);
|
|
154
|
+
if (this.options.forceConsole) {
|
|
155
|
+
if (writeStreamType === 'stderr') {
|
|
156
|
+
console.error(formattedMessage.trim());
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
console.log(formattedMessage.trim());
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
process[writeStreamType ?? 'stdout'].write(formattedMessage);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
printAsJson(message, options) {
|
|
168
|
+
const logObject = this.getJsonLogObject(message, options);
|
|
169
|
+
const formattedMessage = !this.options.colors && this.inspectOptions.compact === true
|
|
170
|
+
? JSON.stringify(logObject, this.stringifyReplacer)
|
|
171
|
+
: (0, util_1.inspect)(logObject, this.inspectOptions);
|
|
172
|
+
if (this.options.forceConsole) {
|
|
173
|
+
if (options.writeStreamType === 'stderr') {
|
|
174
|
+
console.error(formattedMessage);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
console.log(formattedMessage);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
process[options.writeStreamType ?? 'stdout'].write(`${formattedMessage}\n`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
getJsonLogObject(message, options) {
|
|
185
|
+
const logObject = {
|
|
186
|
+
level: options.logLevel,
|
|
187
|
+
pid: process.pid,
|
|
188
|
+
timestamp: Date.now(),
|
|
189
|
+
message,
|
|
190
|
+
};
|
|
191
|
+
if (options.context) {
|
|
192
|
+
logObject.context = options.context;
|
|
193
|
+
}
|
|
194
|
+
if (options.errorStack) {
|
|
195
|
+
logObject.stack = options.errorStack;
|
|
196
|
+
}
|
|
197
|
+
return logObject;
|
|
198
|
+
}
|
|
199
|
+
formatPid(pid) {
|
|
200
|
+
return `[${this.options.prefix}] ${pid} - `;
|
|
201
|
+
}
|
|
202
|
+
formatContext(context) {
|
|
203
|
+
if (!context) {
|
|
204
|
+
return '';
|
|
205
|
+
}
|
|
206
|
+
context = `[${context}] `;
|
|
207
|
+
return this.options.colors ? (0, cli_colors_util_1.yellow)(context) : context;
|
|
208
|
+
}
|
|
209
|
+
formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff) {
|
|
210
|
+
const output = this.stringifyMessage(message, logLevel);
|
|
211
|
+
pidMessage = this.colorize(pidMessage, logLevel);
|
|
212
|
+
formattedLogLevel = this.colorize(formattedLogLevel, logLevel);
|
|
213
|
+
return `${pidMessage}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${output}${timestampDiff}\n`;
|
|
214
|
+
}
|
|
215
|
+
stringifyMessage(message, logLevel) {
|
|
216
|
+
if ((0, shared_utils_1.isFunction)(message)) {
|
|
217
|
+
const messageAsStr = Function.prototype.toString.call(message);
|
|
218
|
+
const isClass = messageAsStr.startsWith('class ');
|
|
219
|
+
if (isClass) {
|
|
220
|
+
// If the message is a class, we will display the class name.
|
|
221
|
+
return this.stringifyMessage(message.name, logLevel);
|
|
222
|
+
}
|
|
223
|
+
// If the message is a non-class function, call it and re-resolve its value.
|
|
224
|
+
return this.stringifyMessage(message(), logLevel);
|
|
225
|
+
}
|
|
226
|
+
if (typeof message === 'string') {
|
|
227
|
+
return this.colorize(message, logLevel);
|
|
228
|
+
}
|
|
229
|
+
const outputText = (0, util_1.inspect)(message, this.inspectOptions);
|
|
230
|
+
if ((0, shared_utils_1.isPlainObject)(message)) {
|
|
231
|
+
return `Object(${Object.keys(message).length}) ${outputText}`;
|
|
232
|
+
}
|
|
233
|
+
if (Array.isArray(message)) {
|
|
234
|
+
return `Array(${message.length}) ${outputText}`;
|
|
235
|
+
}
|
|
236
|
+
return outputText;
|
|
237
|
+
}
|
|
238
|
+
colorize(message, logLevel) {
|
|
239
|
+
if (!this.options.colors || this.options.json) {
|
|
240
|
+
return message;
|
|
241
|
+
}
|
|
242
|
+
const color = this.getColorByLogLevel(logLevel);
|
|
243
|
+
return color(message);
|
|
244
|
+
}
|
|
245
|
+
printStackTrace(stack) {
|
|
246
|
+
if (!stack || this.options.json) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (this.options.forceConsole) {
|
|
250
|
+
console.error(stack);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
process.stderr.write(`${stack}\n`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
updateAndGetTimestampDiff() {
|
|
257
|
+
const includeTimestamp = ConsoleLogger_1.lastTimestampAt && this.options?.timestamp;
|
|
258
|
+
const result = includeTimestamp
|
|
259
|
+
? this.formatTimestampDiff(Date.now() - ConsoleLogger_1.lastTimestampAt)
|
|
260
|
+
: '';
|
|
261
|
+
ConsoleLogger_1.lastTimestampAt = Date.now();
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
formatTimestampDiff(timestampDiff) {
|
|
265
|
+
const formattedDiff = ` +${timestampDiff}ms`;
|
|
266
|
+
return this.options.colors ? (0, cli_colors_util_1.yellow)(formattedDiff) : formattedDiff;
|
|
267
|
+
}
|
|
268
|
+
getInspectOptions() {
|
|
269
|
+
let breakLength = this.options.breakLength;
|
|
270
|
+
if (typeof breakLength === 'undefined') {
|
|
271
|
+
breakLength = this.options.colors
|
|
272
|
+
? this.options.compact
|
|
273
|
+
? Infinity
|
|
274
|
+
: undefined
|
|
275
|
+
: this.options.compact === false
|
|
276
|
+
? undefined
|
|
277
|
+
: Infinity; // default breakLength to Infinity if inline is not set and colors is false
|
|
278
|
+
}
|
|
279
|
+
const inspectOptions = {
|
|
280
|
+
depth: this.options.depth ?? DEFAULT_DEPTH,
|
|
281
|
+
sorted: this.options.sorted,
|
|
282
|
+
showHidden: this.options.showHidden,
|
|
283
|
+
compact: this.options.compact ?? (this.options.json ? true : false),
|
|
284
|
+
colors: this.options.colors,
|
|
285
|
+
breakLength,
|
|
286
|
+
};
|
|
287
|
+
if (typeof this.options.maxArrayLength !== 'undefined') {
|
|
288
|
+
inspectOptions.maxArrayLength = this.options.maxArrayLength;
|
|
289
|
+
}
|
|
290
|
+
if (typeof this.options.maxStringLength !== 'undefined') {
|
|
291
|
+
inspectOptions.maxStringLength = this.options.maxStringLength;
|
|
292
|
+
}
|
|
293
|
+
return inspectOptions;
|
|
294
|
+
}
|
|
295
|
+
stringifyReplacer(key, value) {
|
|
296
|
+
// Mimic util.inspect behavior for JSON logger with compact on and colors off
|
|
297
|
+
if (typeof value === 'bigint') {
|
|
298
|
+
return value.toString();
|
|
299
|
+
}
|
|
300
|
+
if (typeof value === 'symbol') {
|
|
301
|
+
return value.toString();
|
|
302
|
+
}
|
|
303
|
+
if (value instanceof Map ||
|
|
304
|
+
value instanceof Set ||
|
|
305
|
+
value instanceof Error) {
|
|
306
|
+
return `${(0, util_1.inspect)(value, this.inspectOptions)}`;
|
|
307
|
+
}
|
|
308
|
+
return value;
|
|
309
|
+
}
|
|
310
|
+
getContextAndMessagesToPrint(args) {
|
|
311
|
+
if (args?.length <= 1) {
|
|
312
|
+
return { messages: args, context: this.context };
|
|
313
|
+
}
|
|
314
|
+
const lastElement = args[args.length - 1];
|
|
315
|
+
const isContext = (0, shared_utils_1.isString)(lastElement);
|
|
316
|
+
if (!isContext) {
|
|
317
|
+
return { messages: args, context: this.context };
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
context: lastElement,
|
|
321
|
+
messages: args.slice(0, args.length - 1),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
getContextAndStackAndMessagesToPrint(args) {
|
|
325
|
+
if (args.length === 2) {
|
|
326
|
+
return this.isStackFormat(args[1])
|
|
327
|
+
? {
|
|
328
|
+
messages: [args[0]],
|
|
329
|
+
stack: args[1],
|
|
330
|
+
context: this.context,
|
|
331
|
+
}
|
|
332
|
+
: { ...this.getContextAndMessagesToPrint(args) };
|
|
333
|
+
}
|
|
334
|
+
const { messages, context } = this.getContextAndMessagesToPrint(args);
|
|
335
|
+
if (messages?.length <= 1) {
|
|
336
|
+
return { messages, context };
|
|
337
|
+
}
|
|
338
|
+
const lastElement = messages[messages.length - 1];
|
|
339
|
+
const isStack = (0, shared_utils_1.isString)(lastElement);
|
|
340
|
+
// https://github.com/nestjs/nest/issues/11074#issuecomment-1421680060
|
|
341
|
+
if (!isStack && !(0, shared_utils_1.isUndefined)(lastElement)) {
|
|
342
|
+
return { messages, context };
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
stack: lastElement,
|
|
346
|
+
messages: messages.slice(0, messages.length - 1),
|
|
347
|
+
context,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
isStackFormat(stack) {
|
|
351
|
+
if (!(0, shared_utils_1.isString)(stack) && !(0, shared_utils_1.isUndefined)(stack)) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
return /^(.)+\n\s+at .+:\d+:\d+/.test(stack);
|
|
355
|
+
}
|
|
356
|
+
getColorByLogLevel(level) {
|
|
357
|
+
switch (level) {
|
|
358
|
+
case 'debug':
|
|
359
|
+
return cli_colors_util_1.clc.magentaBright;
|
|
360
|
+
case 'warn':
|
|
361
|
+
return cli_colors_util_1.clc.yellow;
|
|
362
|
+
case 'error':
|
|
363
|
+
return cli_colors_util_1.clc.red;
|
|
364
|
+
case 'verbose':
|
|
365
|
+
return cli_colors_util_1.clc.cyanBright;
|
|
366
|
+
case 'fatal':
|
|
367
|
+
return cli_colors_util_1.clc.bold;
|
|
368
|
+
default:
|
|
369
|
+
return cli_colors_util_1.clc.green;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
exports.ConsoleLogger = ConsoleLogger;
|
|
374
|
+
exports.ConsoleLogger = ConsoleLogger = ConsoleLogger_1 = tslib_1.__decorate([
|
|
375
|
+
(0, core_1.Injectable)(),
|
|
376
|
+
tslib_1.__param(0, (0, core_1.Optional)()),
|
|
377
|
+
tslib_1.__param(1, (0, core_1.Optional)()),
|
|
378
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
379
|
+
], ConsoleLogger);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./console-logger.service"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./logger.service"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./utils/filter-log-levels.util"), exports);
|