@bymax-one/nest-logger 1.2.0 → 1.2.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/CHANGELOG.md +160 -1
- package/README.md +238 -19
- package/dist/server/index.cjs +315 -40
- package/dist/server/index.d.cts +164 -14
- package/dist/server/index.d.ts +164 -14
- package/dist/server/index.mjs +327 -49
- package/dist/shared/index.d.cts +113 -3
- package/dist/shared/index.d.ts +113 -3
- package/package.json +1 -1
package/dist/server/index.d.cts
CHANGED
|
@@ -96,6 +96,99 @@ interface ServiceMetadata {
|
|
|
96
96
|
readonly name: string;
|
|
97
97
|
/** OTel attribute `service.version` — semver, commit SHA, or build tag. */
|
|
98
98
|
readonly version: string;
|
|
99
|
+
/**
|
|
100
|
+
* OTel attribute `service.namespace` (**Stable**) — the group the service
|
|
101
|
+
* belongs to, e.g. a team, a bounded context or a tenant of the platform.
|
|
102
|
+
* Two services may share a `name` as long as their namespaces differ.
|
|
103
|
+
*/
|
|
104
|
+
readonly namespace?: string;
|
|
105
|
+
/**
|
|
106
|
+
* OTel attribute `service.instance.id` (**Stable**) — identifies ONE running
|
|
107
|
+
* instance, so the triplet (namespace, name, instanceId) is globally unique.
|
|
108
|
+
*
|
|
109
|
+
* The library never generates this. A value minted here would be the logger's
|
|
110
|
+
* rather than the OpenTelemetry Resource's, so logs and traces would disagree
|
|
111
|
+
* about which instance served a request, and it would change on every restart
|
|
112
|
+
* while looking authoritative. Supply it from the platform — the Kubernetes
|
|
113
|
+
* pod UID, the ECS task ARN, the VM instance id — or through
|
|
114
|
+
* `OTEL_RESOURCE_ATTRIBUTES`, which is the same source the SDK reads.
|
|
115
|
+
*
|
|
116
|
+
* Treat it as HIGH cardinality: fine as a log field, not as a metric label.
|
|
117
|
+
*/
|
|
118
|
+
readonly instanceId?: string;
|
|
119
|
+
/**
|
|
120
|
+
* OTel attribute `deployment.environment.name` (**Stable**) — `production`,
|
|
121
|
+
* `staging`, and so on. Falls back to `NODE_ENV` when omitted.
|
|
122
|
+
*
|
|
123
|
+
* The older `deployment.environment` spelling is **Deprecated** in the
|
|
124
|
+
* semantic conventions and is never emitted.
|
|
125
|
+
*/
|
|
126
|
+
readonly environment?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Service identity after precedence has been applied.
|
|
130
|
+
*
|
|
131
|
+
* Distinct from {@link ServiceMetadata} because the optional fields here mean
|
|
132
|
+
* "resolved to nothing" rather than "not configured": every source — options,
|
|
133
|
+
* `OTEL_SERVICE_NAME`, `OTEL_RESOURCE_ATTRIBUTES`, `NODE_ENV` — has already been
|
|
134
|
+
* consulted, and a field still absent will not appear on any entry.
|
|
135
|
+
*/
|
|
136
|
+
interface ResolvedServiceMetadata {
|
|
137
|
+
/** `service.name`, always present. */
|
|
138
|
+
name: string;
|
|
139
|
+
/** `service.version`, always present. */
|
|
140
|
+
version: string;
|
|
141
|
+
/** `service.namespace`, when any source supplied one. */
|
|
142
|
+
namespace?: string;
|
|
143
|
+
/** `service.instance.id`, when any source supplied one. */
|
|
144
|
+
instanceId?: string;
|
|
145
|
+
/** `deployment.environment.name`, when any source supplied one. */
|
|
146
|
+
environment?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The `service` block as it appears in an EMITTED record, under the default
|
|
150
|
+
* `resourceFormat: 'nested'`.
|
|
151
|
+
*
|
|
152
|
+
* Distinct from {@link ServiceMetadata} on purpose, and the distinction is the
|
|
153
|
+
* kind of defect this library has already been bitten by once: a published type
|
|
154
|
+
* that describes something the runtime never emits. `ServiceMetadata` is what a
|
|
155
|
+
* consumer CONFIGURES — flat option names like `instanceId` and `environment`.
|
|
156
|
+
* What comes out is the flattened OTel attribute path: `service.instance.id`
|
|
157
|
+
* nests as `service: { instance: { id } }`, and the environment is not under
|
|
158
|
+
* `service` at all, it is `deployment.environment.name`. Typing the emitted
|
|
159
|
+
* record with the configuration interface would advertise `entry.service.instanceId`
|
|
160
|
+
* to every consumer, and that property does not exist on any entry.
|
|
161
|
+
*
|
|
162
|
+
* Under `resourceFormat: 'flat'` these values appear as dotted top-level keys
|
|
163
|
+
* (`"service.instance.id"`), which {@link LogEntry}'s index signature already
|
|
164
|
+
* admits — a flat record simply has no `service` object.
|
|
165
|
+
*/
|
|
166
|
+
interface EmittedServiceResource {
|
|
167
|
+
/** OTel `service.name`. */
|
|
168
|
+
readonly name: string;
|
|
169
|
+
/** OTel `service.version`. */
|
|
170
|
+
readonly version: string;
|
|
171
|
+
/** OTel `service.namespace`, when resolved. */
|
|
172
|
+
readonly namespace?: string;
|
|
173
|
+
/** OTel `service.instance.id`, nested as the attribute path spells it. */
|
|
174
|
+
readonly instance?: {
|
|
175
|
+
readonly id: string;
|
|
176
|
+
};
|
|
177
|
+
/** Consumer-supplied extras carried through from the `service` option. */
|
|
178
|
+
readonly [key: string]: unknown;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The `deployment` block as it appears in an EMITTED record under
|
|
182
|
+
* `resourceFormat: 'nested'`, carrying `deployment.environment.name`.
|
|
183
|
+
*
|
|
184
|
+
* Absent entirely when no source resolved an environment. The deprecated
|
|
185
|
+
* `deployment.environment` spelling is never emitted.
|
|
186
|
+
*/
|
|
187
|
+
interface EmittedDeploymentResource {
|
|
188
|
+
/** OTel `deployment.environment.name`, flattened from its attribute path. */
|
|
189
|
+
readonly environment: {
|
|
190
|
+
readonly name: string;
|
|
191
|
+
};
|
|
99
192
|
}
|
|
100
193
|
|
|
101
194
|
/**
|
|
@@ -191,6 +284,52 @@ interface BymaxLoggerModuleOptions {
|
|
|
191
284
|
* path-matching semantics; expect it to be removed in a future major.
|
|
192
285
|
*/
|
|
193
286
|
redactStrategy?: 'names' | 'paths';
|
|
287
|
+
/**
|
|
288
|
+
* Shape of the resource/service identity on every entry. Default `'nested'`.
|
|
289
|
+
*
|
|
290
|
+
* - `'nested'` — `{ service: { name, version, namespace, instance: { id } },
|
|
291
|
+
* deployment: { environment: { name } } }`. The historical shape, extended;
|
|
292
|
+
* no existing query breaks.
|
|
293
|
+
* - `'flat'` — the dotted OTel attribute names verbatim (`service.name`,
|
|
294
|
+
* `service.instance.id`, `deployment.environment.name`), which is what a
|
|
295
|
+
* collector mapping log fields onto resource attributes reads directly.
|
|
296
|
+
*
|
|
297
|
+
* Both carry the same values; only the key shape differs.
|
|
298
|
+
*/
|
|
299
|
+
resourceFormat?: 'nested' | 'flat';
|
|
300
|
+
/**
|
|
301
|
+
* Field carrying the machine-readable event name, mirroring `logKey`.
|
|
302
|
+
* Default `'event.name'`; `false` emits nothing.
|
|
303
|
+
*
|
|
304
|
+
* `logKey` stays exactly as it is — this is additive, never a rename.
|
|
305
|
+
*
|
|
306
|
+
* The value is meant to be mapped onto the **`EventName`** field of the
|
|
307
|
+
* OpenTelemetry LogRecord, which is Stable in the Logs Data Model. Note that
|
|
308
|
+
* the same-named `event.name` *attribute* is Deprecated in the semantic
|
|
309
|
+
* conventions precisely because the value belongs in that top-level field
|
|
310
|
+
* instead; the key here is the JSON carrier, not an OTLP attribute. The name is
|
|
311
|
+
* configurable so a pipeline that maps a different key can use it.
|
|
312
|
+
*
|
|
313
|
+
* Keep event names LOW cardinality — `payment.failed`, not
|
|
314
|
+
* `payment.failed.918231781`. Identifiers belong in their own fields.
|
|
315
|
+
*/
|
|
316
|
+
eventNameField?: string | false;
|
|
317
|
+
/**
|
|
318
|
+
* Shape of the error fields on an entry. Default `'pino'`.
|
|
319
|
+
*
|
|
320
|
+
* - `'pino'` — only the legacy `err` object (`type`, `message`, `stack`,
|
|
321
|
+
* plus the `cause` chain). What every existing query reads.
|
|
322
|
+
* - `'semconv'` — only the OpenTelemetry attributes: `exception.type`,
|
|
323
|
+
* `exception.message`, `exception.stacktrace` and `error.type`. The `err`
|
|
324
|
+
* object is removed, so this is an explicit migration, never a default.
|
|
325
|
+
* - `'both'` — both shapes on the same entry. Recommended while moving
|
|
326
|
+
* dashboards over: nothing breaks, and the new fields are already there.
|
|
327
|
+
*
|
|
328
|
+
* All four attributes are **Stable** in Semantic Conventions v1.44.0.
|
|
329
|
+
* `error.type` carries the error's class name and is LOW cardinality by
|
|
330
|
+
* construction — never a message, never an identifier.
|
|
331
|
+
*/
|
|
332
|
+
errorFormat?: 'pino' | 'semconv' | 'both';
|
|
194
333
|
/** Censor string written in place of redacted values. Default: `[REDACTED]`. */
|
|
195
334
|
redactCensor?: string;
|
|
196
335
|
/** Disable default redact paths (use with caution). Default: false. */
|
|
@@ -393,6 +532,11 @@ declare const RESERVED_LOG_KEYS_NOT_EMITTED: Readonly<{
|
|
|
393
532
|
*/
|
|
394
533
|
readonly HTTP_REQUEST_COMPLETED: "reserved: superseded by the four status-specific terminal keys";
|
|
395
534
|
}>;
|
|
535
|
+
/**
|
|
536
|
+
* Strongly-typed union of every reserved log key value, derived from
|
|
537
|
+
* {@link RESERVED_LOG_KEYS}. Use this type to constrain log-key arguments.
|
|
538
|
+
*/
|
|
539
|
+
type ReservedLogKey = (typeof RESERVED_LOG_KEYS)[keyof typeof RESERVED_LOG_KEYS];
|
|
396
540
|
|
|
397
541
|
/**
|
|
398
542
|
* Name-based recursive redaction.
|
|
@@ -598,17 +742,6 @@ declare class PinoLoggerService implements LoggerService, OnApplicationShutdown
|
|
|
598
742
|
* this service has no additional teardown work.
|
|
599
743
|
*/
|
|
600
744
|
onApplicationShutdown(): void;
|
|
601
|
-
/**
|
|
602
|
-
* Serialize an Error into a plain, log-safe object matching Pino's built-in
|
|
603
|
-
* `err` serializer shape (`type`, `message`, `stack`).
|
|
604
|
-
*
|
|
605
|
-
* Reads `error.name` (NOT `error.constructor.name`) for `type`: native
|
|
606
|
-
* subclasses set `name` to their class name, and a sanitized plain-object error
|
|
607
|
-
* (from `sanitizeError`) carries the real class name on `name` — whereas its
|
|
608
|
-
* `constructor.name` would be the unhelpful `'Object'`, breaking `err.type`
|
|
609
|
-
* dashboards for every exception logged through `HttpExceptionFilter`.
|
|
610
|
-
*/
|
|
611
|
-
private serializeError;
|
|
612
745
|
/** Resolve the context: last string param wins, else the instance context. */
|
|
613
746
|
private resolveContext;
|
|
614
747
|
/** Emit a structured payload at info or warn level. */
|
|
@@ -1179,8 +1312,25 @@ interface LogEntry {
|
|
|
1179
1312
|
msg: string;
|
|
1180
1313
|
/** Convention key — `MODULE_ACTION_RESULT` format. */
|
|
1181
1314
|
logKey?: string;
|
|
1182
|
-
/**
|
|
1183
|
-
|
|
1315
|
+
/**
|
|
1316
|
+
* OTel event name derived from {@link logKey} (`PAYMENT_FAILED` →
|
|
1317
|
+
* `payment.failed`), emitted on structured calls unless `eventNameField` is
|
|
1318
|
+
* `false`. Declared explicitly because the index signature below would type
|
|
1319
|
+
* it `unknown`: a documented field a consumer cannot read without a cast is
|
|
1320
|
+
* not really published.
|
|
1321
|
+
*
|
|
1322
|
+
* The key is configurable, so a renamed field arrives through the index
|
|
1323
|
+
* signature instead — this declaration describes the default only.
|
|
1324
|
+
*/
|
|
1325
|
+
'event.name'?: string;
|
|
1326
|
+
/**
|
|
1327
|
+
* Service identity as EMITTED — see {@link EmittedServiceResource}. Not the
|
|
1328
|
+
* configuration shape: `service.instance.id` nests, and the environment lives
|
|
1329
|
+
* under `deployment`, not here.
|
|
1330
|
+
*/
|
|
1331
|
+
service?: EmittedServiceResource;
|
|
1332
|
+
/** Deployment identity as emitted — see {@link EmittedDeploymentResource}. */
|
|
1333
|
+
deployment?: EmittedDeploymentResource;
|
|
1184
1334
|
/** Optional NestJS context (typically the emitting class name). */
|
|
1185
1335
|
context?: string;
|
|
1186
1336
|
/** Optional correlation IDs propagated via AsyncLocalStorage. */
|
|
@@ -1223,4 +1373,4 @@ interface LogEntry {
|
|
|
1223
1373
|
*/
|
|
1224
1374
|
declare const LOG_KEYS_CONVENTION_REGEX: RegExp;
|
|
1225
1375
|
|
|
1226
|
-
export { BymaxLoggerModule, type BymaxLoggerModuleAsyncOptions, type BymaxLoggerModuleOptions, type BymaxLoggerModuleOptionsFactory, DEFAULT_REDACT_PATHS, DefaultStdoutDestination, HttpExceptionFilter, HttpLoggingInterceptor, type HttpOptions, type ILogDestination, type IncomingHeaders, InjectLogger, LOGGER_DESTINATIONS_TOKEN, LOGGER_OPTIONS_TOKEN, LOGGER_PINO_INSTANCE_TOKEN, LOG_CONTEXT_METADATA_KEY, LOG_CONTEXT_TOKEN, LOG_KEYS_CONVENTION_REGEX, LogContext, type LogContext$1 as LogContextBag, LogContextService, type LogEntry, type LogLevel, LogPerformance, type LoggableRequest, type LoggableResponse, type NextHandler, type OtelOptions, PINO_LEVEL_NAMES, PINO_LEVEL_NUMBERS, PinoLoggerService, PrettyDevDestination, RESERVED_LOG_KEYS, RESERVED_LOG_KEYS_NOT_EMITTED, RequestIdMiddleware, type ResolvedBymaxLoggerModuleOptions, type ServiceMetadata, applyRequestIdMiddleware };
|
|
1376
|
+
export { BymaxLoggerModule, type BymaxLoggerModuleAsyncOptions, type BymaxLoggerModuleOptions, type BymaxLoggerModuleOptionsFactory, DEFAULT_REDACT_PATHS, DefaultStdoutDestination, type EmittedDeploymentResource, type EmittedServiceResource, HttpExceptionFilter, HttpLoggingInterceptor, type HttpOptions, type ILogDestination, type IncomingHeaders, InjectLogger, LOGGER_DESTINATIONS_TOKEN, LOGGER_OPTIONS_TOKEN, LOGGER_PINO_INSTANCE_TOKEN, LOG_CONTEXT_METADATA_KEY, LOG_CONTEXT_TOKEN, LOG_KEYS_CONVENTION_REGEX, LogContext, type LogContext$1 as LogContextBag, LogContextService, type LogEntry, type LogLevel, LogPerformance, type LoggableRequest, type LoggableResponse, type NextHandler, type OtelOptions, PINO_LEVEL_NAMES, PINO_LEVEL_NUMBERS, PinoLoggerService, PrettyDevDestination, RESERVED_LOG_KEYS, RESERVED_LOG_KEYS_NOT_EMITTED, RequestIdMiddleware, type ReservedLogKey, type ResolvedBymaxLoggerModuleOptions, type ResolvedServiceMetadata, type ServiceMetadata, applyRequestIdMiddleware };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -96,6 +96,99 @@ interface ServiceMetadata {
|
|
|
96
96
|
readonly name: string;
|
|
97
97
|
/** OTel attribute `service.version` — semver, commit SHA, or build tag. */
|
|
98
98
|
readonly version: string;
|
|
99
|
+
/**
|
|
100
|
+
* OTel attribute `service.namespace` (**Stable**) — the group the service
|
|
101
|
+
* belongs to, e.g. a team, a bounded context or a tenant of the platform.
|
|
102
|
+
* Two services may share a `name` as long as their namespaces differ.
|
|
103
|
+
*/
|
|
104
|
+
readonly namespace?: string;
|
|
105
|
+
/**
|
|
106
|
+
* OTel attribute `service.instance.id` (**Stable**) — identifies ONE running
|
|
107
|
+
* instance, so the triplet (namespace, name, instanceId) is globally unique.
|
|
108
|
+
*
|
|
109
|
+
* The library never generates this. A value minted here would be the logger's
|
|
110
|
+
* rather than the OpenTelemetry Resource's, so logs and traces would disagree
|
|
111
|
+
* about which instance served a request, and it would change on every restart
|
|
112
|
+
* while looking authoritative. Supply it from the platform — the Kubernetes
|
|
113
|
+
* pod UID, the ECS task ARN, the VM instance id — or through
|
|
114
|
+
* `OTEL_RESOURCE_ATTRIBUTES`, which is the same source the SDK reads.
|
|
115
|
+
*
|
|
116
|
+
* Treat it as HIGH cardinality: fine as a log field, not as a metric label.
|
|
117
|
+
*/
|
|
118
|
+
readonly instanceId?: string;
|
|
119
|
+
/**
|
|
120
|
+
* OTel attribute `deployment.environment.name` (**Stable**) — `production`,
|
|
121
|
+
* `staging`, and so on. Falls back to `NODE_ENV` when omitted.
|
|
122
|
+
*
|
|
123
|
+
* The older `deployment.environment` spelling is **Deprecated** in the
|
|
124
|
+
* semantic conventions and is never emitted.
|
|
125
|
+
*/
|
|
126
|
+
readonly environment?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Service identity after precedence has been applied.
|
|
130
|
+
*
|
|
131
|
+
* Distinct from {@link ServiceMetadata} because the optional fields here mean
|
|
132
|
+
* "resolved to nothing" rather than "not configured": every source — options,
|
|
133
|
+
* `OTEL_SERVICE_NAME`, `OTEL_RESOURCE_ATTRIBUTES`, `NODE_ENV` — has already been
|
|
134
|
+
* consulted, and a field still absent will not appear on any entry.
|
|
135
|
+
*/
|
|
136
|
+
interface ResolvedServiceMetadata {
|
|
137
|
+
/** `service.name`, always present. */
|
|
138
|
+
name: string;
|
|
139
|
+
/** `service.version`, always present. */
|
|
140
|
+
version: string;
|
|
141
|
+
/** `service.namespace`, when any source supplied one. */
|
|
142
|
+
namespace?: string;
|
|
143
|
+
/** `service.instance.id`, when any source supplied one. */
|
|
144
|
+
instanceId?: string;
|
|
145
|
+
/** `deployment.environment.name`, when any source supplied one. */
|
|
146
|
+
environment?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The `service` block as it appears in an EMITTED record, under the default
|
|
150
|
+
* `resourceFormat: 'nested'`.
|
|
151
|
+
*
|
|
152
|
+
* Distinct from {@link ServiceMetadata} on purpose, and the distinction is the
|
|
153
|
+
* kind of defect this library has already been bitten by once: a published type
|
|
154
|
+
* that describes something the runtime never emits. `ServiceMetadata` is what a
|
|
155
|
+
* consumer CONFIGURES — flat option names like `instanceId` and `environment`.
|
|
156
|
+
* What comes out is the flattened OTel attribute path: `service.instance.id`
|
|
157
|
+
* nests as `service: { instance: { id } }`, and the environment is not under
|
|
158
|
+
* `service` at all, it is `deployment.environment.name`. Typing the emitted
|
|
159
|
+
* record with the configuration interface would advertise `entry.service.instanceId`
|
|
160
|
+
* to every consumer, and that property does not exist on any entry.
|
|
161
|
+
*
|
|
162
|
+
* Under `resourceFormat: 'flat'` these values appear as dotted top-level keys
|
|
163
|
+
* (`"service.instance.id"`), which {@link LogEntry}'s index signature already
|
|
164
|
+
* admits — a flat record simply has no `service` object.
|
|
165
|
+
*/
|
|
166
|
+
interface EmittedServiceResource {
|
|
167
|
+
/** OTel `service.name`. */
|
|
168
|
+
readonly name: string;
|
|
169
|
+
/** OTel `service.version`. */
|
|
170
|
+
readonly version: string;
|
|
171
|
+
/** OTel `service.namespace`, when resolved. */
|
|
172
|
+
readonly namespace?: string;
|
|
173
|
+
/** OTel `service.instance.id`, nested as the attribute path spells it. */
|
|
174
|
+
readonly instance?: {
|
|
175
|
+
readonly id: string;
|
|
176
|
+
};
|
|
177
|
+
/** Consumer-supplied extras carried through from the `service` option. */
|
|
178
|
+
readonly [key: string]: unknown;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The `deployment` block as it appears in an EMITTED record under
|
|
182
|
+
* `resourceFormat: 'nested'`, carrying `deployment.environment.name`.
|
|
183
|
+
*
|
|
184
|
+
* Absent entirely when no source resolved an environment. The deprecated
|
|
185
|
+
* `deployment.environment` spelling is never emitted.
|
|
186
|
+
*/
|
|
187
|
+
interface EmittedDeploymentResource {
|
|
188
|
+
/** OTel `deployment.environment.name`, flattened from its attribute path. */
|
|
189
|
+
readonly environment: {
|
|
190
|
+
readonly name: string;
|
|
191
|
+
};
|
|
99
192
|
}
|
|
100
193
|
|
|
101
194
|
/**
|
|
@@ -191,6 +284,52 @@ interface BymaxLoggerModuleOptions {
|
|
|
191
284
|
* path-matching semantics; expect it to be removed in a future major.
|
|
192
285
|
*/
|
|
193
286
|
redactStrategy?: 'names' | 'paths';
|
|
287
|
+
/**
|
|
288
|
+
* Shape of the resource/service identity on every entry. Default `'nested'`.
|
|
289
|
+
*
|
|
290
|
+
* - `'nested'` — `{ service: { name, version, namespace, instance: { id } },
|
|
291
|
+
* deployment: { environment: { name } } }`. The historical shape, extended;
|
|
292
|
+
* no existing query breaks.
|
|
293
|
+
* - `'flat'` — the dotted OTel attribute names verbatim (`service.name`,
|
|
294
|
+
* `service.instance.id`, `deployment.environment.name`), which is what a
|
|
295
|
+
* collector mapping log fields onto resource attributes reads directly.
|
|
296
|
+
*
|
|
297
|
+
* Both carry the same values; only the key shape differs.
|
|
298
|
+
*/
|
|
299
|
+
resourceFormat?: 'nested' | 'flat';
|
|
300
|
+
/**
|
|
301
|
+
* Field carrying the machine-readable event name, mirroring `logKey`.
|
|
302
|
+
* Default `'event.name'`; `false` emits nothing.
|
|
303
|
+
*
|
|
304
|
+
* `logKey` stays exactly as it is — this is additive, never a rename.
|
|
305
|
+
*
|
|
306
|
+
* The value is meant to be mapped onto the **`EventName`** field of the
|
|
307
|
+
* OpenTelemetry LogRecord, which is Stable in the Logs Data Model. Note that
|
|
308
|
+
* the same-named `event.name` *attribute* is Deprecated in the semantic
|
|
309
|
+
* conventions precisely because the value belongs in that top-level field
|
|
310
|
+
* instead; the key here is the JSON carrier, not an OTLP attribute. The name is
|
|
311
|
+
* configurable so a pipeline that maps a different key can use it.
|
|
312
|
+
*
|
|
313
|
+
* Keep event names LOW cardinality — `payment.failed`, not
|
|
314
|
+
* `payment.failed.918231781`. Identifiers belong in their own fields.
|
|
315
|
+
*/
|
|
316
|
+
eventNameField?: string | false;
|
|
317
|
+
/**
|
|
318
|
+
* Shape of the error fields on an entry. Default `'pino'`.
|
|
319
|
+
*
|
|
320
|
+
* - `'pino'` — only the legacy `err` object (`type`, `message`, `stack`,
|
|
321
|
+
* plus the `cause` chain). What every existing query reads.
|
|
322
|
+
* - `'semconv'` — only the OpenTelemetry attributes: `exception.type`,
|
|
323
|
+
* `exception.message`, `exception.stacktrace` and `error.type`. The `err`
|
|
324
|
+
* object is removed, so this is an explicit migration, never a default.
|
|
325
|
+
* - `'both'` — both shapes on the same entry. Recommended while moving
|
|
326
|
+
* dashboards over: nothing breaks, and the new fields are already there.
|
|
327
|
+
*
|
|
328
|
+
* All four attributes are **Stable** in Semantic Conventions v1.44.0.
|
|
329
|
+
* `error.type` carries the error's class name and is LOW cardinality by
|
|
330
|
+
* construction — never a message, never an identifier.
|
|
331
|
+
*/
|
|
332
|
+
errorFormat?: 'pino' | 'semconv' | 'both';
|
|
194
333
|
/** Censor string written in place of redacted values. Default: `[REDACTED]`. */
|
|
195
334
|
redactCensor?: string;
|
|
196
335
|
/** Disable default redact paths (use with caution). Default: false. */
|
|
@@ -393,6 +532,11 @@ declare const RESERVED_LOG_KEYS_NOT_EMITTED: Readonly<{
|
|
|
393
532
|
*/
|
|
394
533
|
readonly HTTP_REQUEST_COMPLETED: "reserved: superseded by the four status-specific terminal keys";
|
|
395
534
|
}>;
|
|
535
|
+
/**
|
|
536
|
+
* Strongly-typed union of every reserved log key value, derived from
|
|
537
|
+
* {@link RESERVED_LOG_KEYS}. Use this type to constrain log-key arguments.
|
|
538
|
+
*/
|
|
539
|
+
type ReservedLogKey = (typeof RESERVED_LOG_KEYS)[keyof typeof RESERVED_LOG_KEYS];
|
|
396
540
|
|
|
397
541
|
/**
|
|
398
542
|
* Name-based recursive redaction.
|
|
@@ -598,17 +742,6 @@ declare class PinoLoggerService implements LoggerService, OnApplicationShutdown
|
|
|
598
742
|
* this service has no additional teardown work.
|
|
599
743
|
*/
|
|
600
744
|
onApplicationShutdown(): void;
|
|
601
|
-
/**
|
|
602
|
-
* Serialize an Error into a plain, log-safe object matching Pino's built-in
|
|
603
|
-
* `err` serializer shape (`type`, `message`, `stack`).
|
|
604
|
-
*
|
|
605
|
-
* Reads `error.name` (NOT `error.constructor.name`) for `type`: native
|
|
606
|
-
* subclasses set `name` to their class name, and a sanitized plain-object error
|
|
607
|
-
* (from `sanitizeError`) carries the real class name on `name` — whereas its
|
|
608
|
-
* `constructor.name` would be the unhelpful `'Object'`, breaking `err.type`
|
|
609
|
-
* dashboards for every exception logged through `HttpExceptionFilter`.
|
|
610
|
-
*/
|
|
611
|
-
private serializeError;
|
|
612
745
|
/** Resolve the context: last string param wins, else the instance context. */
|
|
613
746
|
private resolveContext;
|
|
614
747
|
/** Emit a structured payload at info or warn level. */
|
|
@@ -1179,8 +1312,25 @@ interface LogEntry {
|
|
|
1179
1312
|
msg: string;
|
|
1180
1313
|
/** Convention key — `MODULE_ACTION_RESULT` format. */
|
|
1181
1314
|
logKey?: string;
|
|
1182
|
-
/**
|
|
1183
|
-
|
|
1315
|
+
/**
|
|
1316
|
+
* OTel event name derived from {@link logKey} (`PAYMENT_FAILED` →
|
|
1317
|
+
* `payment.failed`), emitted on structured calls unless `eventNameField` is
|
|
1318
|
+
* `false`. Declared explicitly because the index signature below would type
|
|
1319
|
+
* it `unknown`: a documented field a consumer cannot read without a cast is
|
|
1320
|
+
* not really published.
|
|
1321
|
+
*
|
|
1322
|
+
* The key is configurable, so a renamed field arrives through the index
|
|
1323
|
+
* signature instead — this declaration describes the default only.
|
|
1324
|
+
*/
|
|
1325
|
+
'event.name'?: string;
|
|
1326
|
+
/**
|
|
1327
|
+
* Service identity as EMITTED — see {@link EmittedServiceResource}. Not the
|
|
1328
|
+
* configuration shape: `service.instance.id` nests, and the environment lives
|
|
1329
|
+
* under `deployment`, not here.
|
|
1330
|
+
*/
|
|
1331
|
+
service?: EmittedServiceResource;
|
|
1332
|
+
/** Deployment identity as emitted — see {@link EmittedDeploymentResource}. */
|
|
1333
|
+
deployment?: EmittedDeploymentResource;
|
|
1184
1334
|
/** Optional NestJS context (typically the emitting class name). */
|
|
1185
1335
|
context?: string;
|
|
1186
1336
|
/** Optional correlation IDs propagated via AsyncLocalStorage. */
|
|
@@ -1223,4 +1373,4 @@ interface LogEntry {
|
|
|
1223
1373
|
*/
|
|
1224
1374
|
declare const LOG_KEYS_CONVENTION_REGEX: RegExp;
|
|
1225
1375
|
|
|
1226
|
-
export { BymaxLoggerModule, type BymaxLoggerModuleAsyncOptions, type BymaxLoggerModuleOptions, type BymaxLoggerModuleOptionsFactory, DEFAULT_REDACT_PATHS, DefaultStdoutDestination, HttpExceptionFilter, HttpLoggingInterceptor, type HttpOptions, type ILogDestination, type IncomingHeaders, InjectLogger, LOGGER_DESTINATIONS_TOKEN, LOGGER_OPTIONS_TOKEN, LOGGER_PINO_INSTANCE_TOKEN, LOG_CONTEXT_METADATA_KEY, LOG_CONTEXT_TOKEN, LOG_KEYS_CONVENTION_REGEX, LogContext, type LogContext$1 as LogContextBag, LogContextService, type LogEntry, type LogLevel, LogPerformance, type LoggableRequest, type LoggableResponse, type NextHandler, type OtelOptions, PINO_LEVEL_NAMES, PINO_LEVEL_NUMBERS, PinoLoggerService, PrettyDevDestination, RESERVED_LOG_KEYS, RESERVED_LOG_KEYS_NOT_EMITTED, RequestIdMiddleware, type ResolvedBymaxLoggerModuleOptions, type ServiceMetadata, applyRequestIdMiddleware };
|
|
1376
|
+
export { BymaxLoggerModule, type BymaxLoggerModuleAsyncOptions, type BymaxLoggerModuleOptions, type BymaxLoggerModuleOptionsFactory, DEFAULT_REDACT_PATHS, DefaultStdoutDestination, type EmittedDeploymentResource, type EmittedServiceResource, HttpExceptionFilter, HttpLoggingInterceptor, type HttpOptions, type ILogDestination, type IncomingHeaders, InjectLogger, LOGGER_DESTINATIONS_TOKEN, LOGGER_OPTIONS_TOKEN, LOGGER_PINO_INSTANCE_TOKEN, LOG_CONTEXT_METADATA_KEY, LOG_CONTEXT_TOKEN, LOG_KEYS_CONVENTION_REGEX, LogContext, type LogContext$1 as LogContextBag, LogContextService, type LogEntry, type LogLevel, LogPerformance, type LoggableRequest, type LoggableResponse, type NextHandler, type OtelOptions, PINO_LEVEL_NAMES, PINO_LEVEL_NUMBERS, PinoLoggerService, PrettyDevDestination, RESERVED_LOG_KEYS, RESERVED_LOG_KEYS_NOT_EMITTED, RequestIdMiddleware, type ReservedLogKey, type ResolvedBymaxLoggerModuleOptions, type ResolvedServiceMetadata, type ServiceMetadata, applyRequestIdMiddleware };
|