@bymax-one/nest-logger 1.4.10 → 1.4.12
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/CHANGELOG.md +92 -1
- package/README.md +53 -23
- package/dist/server/index.cjs +800 -612
- package/dist/server/index.d.cts +41 -1
- package/dist/server/index.d.ts +41 -1
- package/dist/server/index.mjs +800 -612
- package/package.json +1 -1
package/dist/server/index.d.cts
CHANGED
|
@@ -251,6 +251,8 @@ interface EmittedDeploymentResource {
|
|
|
251
251
|
* can branch on shape without runtime discrimination.
|
|
252
252
|
*/
|
|
253
253
|
|
|
254
|
+
/** Which of an error's own fields are written: every one, or an allow-list. See `errorOwnFields`. */
|
|
255
|
+
type ErrorOwnFieldsMode = 'all' | 'safe';
|
|
254
256
|
/**
|
|
255
257
|
* HTTP module configuration — used by the optional HTTP interceptor and filter.
|
|
256
258
|
*
|
|
@@ -426,6 +428,26 @@ interface BymaxLoggerModuleOptions {
|
|
|
426
428
|
otel?: OtelOptions;
|
|
427
429
|
/** Maximum size in bytes per log entry. Default: 65536. */
|
|
428
430
|
maxEntrySizeBytes?: number;
|
|
431
|
+
/**
|
|
432
|
+
* Which of an error's own fields are written beside its `type`, `message`, `stack` and `cause`.
|
|
433
|
+
*
|
|
434
|
+
* - `'all'` (default) writes every own field, at every depth of the chain and for an `Error`
|
|
435
|
+
* nested in the metadata. A binary value (a Buffer, a typed array, a DataView, or a member of an
|
|
436
|
+
* array) is written as its size, such as `[Binary 42 bytes]`, never as bytes.
|
|
437
|
+
* - `'safe'` writes only an allow-list of operational names (`code`, `errno`, `syscall`,
|
|
438
|
+
* `signal`, `status`, `statusCode`, `address`, `port`, `hostname`, and the PostgreSQL
|
|
439
|
+
* `constraint`, `table`, `column`, `schema`, `routine`) plus {@link errorOwnFieldNames}. Node's
|
|
440
|
+
* own errors carry values (a child process's `stdout`, an `AssertionError`'s `actual` and
|
|
441
|
+
* `expected`, a file system `path`), and a list of names to drop cannot name them all.
|
|
442
|
+
*
|
|
443
|
+
* Recommended: `'safe'`. The default stays `'all'` for the 1.x line.
|
|
444
|
+
*/
|
|
445
|
+
errorOwnFields?: ErrorOwnFieldsMode;
|
|
446
|
+
/**
|
|
447
|
+
* Own-field names written in `'safe'` mode beside the default list, matched exactly (case
|
|
448
|
+
* included). Ignored in `'all'` mode. Default: none.
|
|
449
|
+
*/
|
|
450
|
+
errorOwnFieldNames?: readonly string[];
|
|
429
451
|
/** Custom Pino serializers, merged with defaults. */
|
|
430
452
|
serializers?: Record<string, (input: unknown) => unknown>;
|
|
431
453
|
/** Custom timestamp function. Default: `() => new Date().toISOString()`. */
|
|
@@ -557,6 +579,24 @@ declare class BymaxLoggerModule extends BymaxLoggerModuleBase {
|
|
|
557
579
|
* await app.listen(3000)
|
|
558
580
|
*/
|
|
559
581
|
static useNestLogger(app: INestApplication): void;
|
|
582
|
+
/**
|
|
583
|
+
* Open the request-id correlation scope ahead of the body parser, so a request the parser
|
|
584
|
+
* refuses (malformed JSON, an unsupported content encoding, a body over the limit) still has its
|
|
585
|
+
* `requestId`, and the `x-request-id` response header, where an exception filter reads it.
|
|
586
|
+
*
|
|
587
|
+
* Call once in `main.ts` AFTER creating the app and BEFORE `app.init()` / `app.listen(...)`.
|
|
588
|
+
* It mounts only the scope. `applyAccessLog(app)` and `applyRequestIdMiddleware(consumer)` can
|
|
589
|
+
* be used as well: a second mount of the middleware reuses the scope this one opened.
|
|
590
|
+
*
|
|
591
|
+
* @param app - The Nest application returned by `NestFactory.create()`.
|
|
592
|
+
* @throws Error When `BymaxLoggerModule` was not imported.
|
|
593
|
+
* @example
|
|
594
|
+
* const app = await NestFactory.create(AppModule, { bufferLogs: true })
|
|
595
|
+
* BymaxLoggerModule.useNestLogger(app)
|
|
596
|
+
* BymaxLoggerModule.useRequestContext(app)
|
|
597
|
+
* await app.listen(3000)
|
|
598
|
+
*/
|
|
599
|
+
static useRequestContext(app: INestApplication): void;
|
|
560
600
|
}
|
|
561
601
|
|
|
562
602
|
/**
|
|
@@ -1939,4 +1979,4 @@ interface LogEntry {
|
|
|
1939
1979
|
declare const LOG_KEYS_CONVENTION_REGEX: RegExp;
|
|
1940
1980
|
|
|
1941
1981
|
export { BymaxLoggerModule, DEFAULT_REDACT_PATHS, DefaultStdoutDestination, HttpAccessLogMiddleware, HttpExceptionFilter, HttpLoggingInterceptor, InjectLogger, LOGGER_DESTINATIONS_TOKEN, LOGGER_OPTIONS_TOKEN, LOGGER_PINO_INSTANCE_TOKEN, LOGGER_REDACTOR_TOKEN, LOG_CONTEXT_METADATA_KEY, LOG_CONTEXT_TOKEN, LOG_KEYS_CONVENTION_REGEX, LogContext, LogContextService, LogPerformance, PINO_LEVEL_NAMES, PINO_LEVEL_NUMBERS, PinoLoggerService, PinoUnexpectedErrorSink, PrettyDevDestination, REDACT_COMMON_FIELDS, RESERVED_LOG_KEYS, RESERVED_LOG_KEYS_NOT_EMITTED, RequestIdMiddleware, applyAccessLog, applyRequestIdMiddleware, isValidTraceId };
|
|
1942
|
-
export type { BymaxLoggerModuleAsyncOptions, BymaxLoggerModuleOptions, BymaxLoggerModuleOptionsFactory, EmittedDeploymentResource, EmittedServiceResource, HttpOptions, ILogDestination, IUnexpectedErrorSink, IncomingHeaders, LogContext$1 as LogContextBag, LogEntry, LogLevel, LoggableRequest, LoggableResponse, NextHandler, OtelOptions, PrettyViewOptions, ReservedLogKey, ResolvedBymaxLoggerModuleOptions, ResolvedServiceMetadata, ServiceMetadata, UnexpectedErrorReport };
|
|
1982
|
+
export type { BymaxLoggerModuleAsyncOptions, BymaxLoggerModuleOptions, BymaxLoggerModuleOptionsFactory, EmittedDeploymentResource, EmittedServiceResource, ErrorOwnFieldsMode, HttpOptions, ILogDestination, IUnexpectedErrorSink, IncomingHeaders, LogContext$1 as LogContextBag, LogEntry, LogLevel, LoggableRequest, LoggableResponse, NextHandler, OtelOptions, PrettyViewOptions, ReservedLogKey, ResolvedBymaxLoggerModuleOptions, ResolvedServiceMetadata, ServiceMetadata, UnexpectedErrorReport };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -251,6 +251,8 @@ interface EmittedDeploymentResource {
|
|
|
251
251
|
* can branch on shape without runtime discrimination.
|
|
252
252
|
*/
|
|
253
253
|
|
|
254
|
+
/** Which of an error's own fields are written: every one, or an allow-list. See `errorOwnFields`. */
|
|
255
|
+
type ErrorOwnFieldsMode = 'all' | 'safe';
|
|
254
256
|
/**
|
|
255
257
|
* HTTP module configuration — used by the optional HTTP interceptor and filter.
|
|
256
258
|
*
|
|
@@ -426,6 +428,26 @@ interface BymaxLoggerModuleOptions {
|
|
|
426
428
|
otel?: OtelOptions;
|
|
427
429
|
/** Maximum size in bytes per log entry. Default: 65536. */
|
|
428
430
|
maxEntrySizeBytes?: number;
|
|
431
|
+
/**
|
|
432
|
+
* Which of an error's own fields are written beside its `type`, `message`, `stack` and `cause`.
|
|
433
|
+
*
|
|
434
|
+
* - `'all'` (default) writes every own field, at every depth of the chain and for an `Error`
|
|
435
|
+
* nested in the metadata. A binary value (a Buffer, a typed array, a DataView, or a member of an
|
|
436
|
+
* array) is written as its size, such as `[Binary 42 bytes]`, never as bytes.
|
|
437
|
+
* - `'safe'` writes only an allow-list of operational names (`code`, `errno`, `syscall`,
|
|
438
|
+
* `signal`, `status`, `statusCode`, `address`, `port`, `hostname`, and the PostgreSQL
|
|
439
|
+
* `constraint`, `table`, `column`, `schema`, `routine`) plus {@link errorOwnFieldNames}. Node's
|
|
440
|
+
* own errors carry values (a child process's `stdout`, an `AssertionError`'s `actual` and
|
|
441
|
+
* `expected`, a file system `path`), and a list of names to drop cannot name them all.
|
|
442
|
+
*
|
|
443
|
+
* Recommended: `'safe'`. The default stays `'all'` for the 1.x line.
|
|
444
|
+
*/
|
|
445
|
+
errorOwnFields?: ErrorOwnFieldsMode;
|
|
446
|
+
/**
|
|
447
|
+
* Own-field names written in `'safe'` mode beside the default list, matched exactly (case
|
|
448
|
+
* included). Ignored in `'all'` mode. Default: none.
|
|
449
|
+
*/
|
|
450
|
+
errorOwnFieldNames?: readonly string[];
|
|
429
451
|
/** Custom Pino serializers, merged with defaults. */
|
|
430
452
|
serializers?: Record<string, (input: unknown) => unknown>;
|
|
431
453
|
/** Custom timestamp function. Default: `() => new Date().toISOString()`. */
|
|
@@ -557,6 +579,24 @@ declare class BymaxLoggerModule extends BymaxLoggerModuleBase {
|
|
|
557
579
|
* await app.listen(3000)
|
|
558
580
|
*/
|
|
559
581
|
static useNestLogger(app: INestApplication): void;
|
|
582
|
+
/**
|
|
583
|
+
* Open the request-id correlation scope ahead of the body parser, so a request the parser
|
|
584
|
+
* refuses (malformed JSON, an unsupported content encoding, a body over the limit) still has its
|
|
585
|
+
* `requestId`, and the `x-request-id` response header, where an exception filter reads it.
|
|
586
|
+
*
|
|
587
|
+
* Call once in `main.ts` AFTER creating the app and BEFORE `app.init()` / `app.listen(...)`.
|
|
588
|
+
* It mounts only the scope. `applyAccessLog(app)` and `applyRequestIdMiddleware(consumer)` can
|
|
589
|
+
* be used as well: a second mount of the middleware reuses the scope this one opened.
|
|
590
|
+
*
|
|
591
|
+
* @param app - The Nest application returned by `NestFactory.create()`.
|
|
592
|
+
* @throws Error When `BymaxLoggerModule` was not imported.
|
|
593
|
+
* @example
|
|
594
|
+
* const app = await NestFactory.create(AppModule, { bufferLogs: true })
|
|
595
|
+
* BymaxLoggerModule.useNestLogger(app)
|
|
596
|
+
* BymaxLoggerModule.useRequestContext(app)
|
|
597
|
+
* await app.listen(3000)
|
|
598
|
+
*/
|
|
599
|
+
static useRequestContext(app: INestApplication): void;
|
|
560
600
|
}
|
|
561
601
|
|
|
562
602
|
/**
|
|
@@ -1939,4 +1979,4 @@ interface LogEntry {
|
|
|
1939
1979
|
declare const LOG_KEYS_CONVENTION_REGEX: RegExp;
|
|
1940
1980
|
|
|
1941
1981
|
export { BymaxLoggerModule, DEFAULT_REDACT_PATHS, DefaultStdoutDestination, HttpAccessLogMiddleware, HttpExceptionFilter, HttpLoggingInterceptor, InjectLogger, LOGGER_DESTINATIONS_TOKEN, LOGGER_OPTIONS_TOKEN, LOGGER_PINO_INSTANCE_TOKEN, LOGGER_REDACTOR_TOKEN, LOG_CONTEXT_METADATA_KEY, LOG_CONTEXT_TOKEN, LOG_KEYS_CONVENTION_REGEX, LogContext, LogContextService, LogPerformance, PINO_LEVEL_NAMES, PINO_LEVEL_NUMBERS, PinoLoggerService, PinoUnexpectedErrorSink, PrettyDevDestination, REDACT_COMMON_FIELDS, RESERVED_LOG_KEYS, RESERVED_LOG_KEYS_NOT_EMITTED, RequestIdMiddleware, applyAccessLog, applyRequestIdMiddleware, isValidTraceId };
|
|
1942
|
-
export type { BymaxLoggerModuleAsyncOptions, BymaxLoggerModuleOptions, BymaxLoggerModuleOptionsFactory, EmittedDeploymentResource, EmittedServiceResource, HttpOptions, ILogDestination, IUnexpectedErrorSink, IncomingHeaders, LogContext$1 as LogContextBag, LogEntry, LogLevel, LoggableRequest, LoggableResponse, NextHandler, OtelOptions, PrettyViewOptions, ReservedLogKey, ResolvedBymaxLoggerModuleOptions, ResolvedServiceMetadata, ServiceMetadata, UnexpectedErrorReport };
|
|
1982
|
+
export type { BymaxLoggerModuleAsyncOptions, BymaxLoggerModuleOptions, BymaxLoggerModuleOptionsFactory, EmittedDeploymentResource, EmittedServiceResource, ErrorOwnFieldsMode, HttpOptions, ILogDestination, IUnexpectedErrorSink, IncomingHeaders, LogContext$1 as LogContextBag, LogEntry, LogLevel, LoggableRequest, LoggableResponse, NextHandler, OtelOptions, PrettyViewOptions, ReservedLogKey, ResolvedBymaxLoggerModuleOptions, ResolvedServiceMetadata, ServiceMetadata, UnexpectedErrorReport };
|