@loglayer/mixin-datadog-http-metrics 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +62 -0
- package/dist/index.cjs +526 -0
- package/dist/index.d.cts +1735 -0
- package/dist/index.d.mts +1735 -0
- package/dist/index.mjs +539 -0
- package/package.json +65 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1735 @@
|
|
|
1
|
+
import metrics, { BufferedMetricsLogger as BufferedMetricsLogger$1, BufferedMetricsLoggerOptions, BufferedMetricsLoggerOptions as BufferedMetricsLoggerOptions$1 } from "datadog-metrics";
|
|
2
|
+
|
|
3
|
+
//#region ../../core/shared/dist/index.d.ts
|
|
4
|
+
//#region src/common.types.d.ts
|
|
5
|
+
declare enum LogLevel {
|
|
6
|
+
info = "info",
|
|
7
|
+
warn = "warn",
|
|
8
|
+
error = "error",
|
|
9
|
+
debug = "debug",
|
|
10
|
+
trace = "trace",
|
|
11
|
+
fatal = "fatal"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Combination of the LogLevel enum and its string representations.
|
|
15
|
+
*/
|
|
16
|
+
type LogLevelType = LogLevel | `${LogLevel}`;
|
|
17
|
+
/**
|
|
18
|
+
* Mapping of log levels to their numeric values.
|
|
19
|
+
*/
|
|
20
|
+
type MessageDataType = string | number | boolean | null | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Options for the `errorOnly` method.
|
|
23
|
+
* @see {@link https://loglayer.dev/logging-api/error-handling.html#error-only-logging | Error Only Logging Doc}
|
|
24
|
+
*/
|
|
25
|
+
interface ErrorOnlyOpts {
|
|
26
|
+
/**
|
|
27
|
+
* Sets the log level of the error
|
|
28
|
+
*/
|
|
29
|
+
logLevel?: LogLevel;
|
|
30
|
+
/**
|
|
31
|
+
* If `true`, copies the `error.message` if available to the transport library's
|
|
32
|
+
* message property.
|
|
33
|
+
*
|
|
34
|
+
* If the config option `error.copyMsgOnOnlyError` is enabled, this property
|
|
35
|
+
* can be set to `true` to disable the behavior for this specific log entry.
|
|
36
|
+
*/
|
|
37
|
+
copyMsg?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Defines the structure for context data that persists across multiple log entries
|
|
41
|
+
* within the same context scope. This is set using log.withContext().
|
|
42
|
+
*/
|
|
43
|
+
interface LogLayerContext extends Record<string, any> {}
|
|
44
|
+
/**
|
|
45
|
+
* Defines the structure for metadata that can be attached to individual log entries.
|
|
46
|
+
* This is set using log.withMetadata() or log.metadataOnly().
|
|
47
|
+
*/
|
|
48
|
+
interface LogLayerMetadata extends Record<string, any> {}
|
|
49
|
+
/**
|
|
50
|
+
* Used internally by LogLayer when assembling the final data object (metadata / context / error) sent to transports.
|
|
51
|
+
*/
|
|
52
|
+
interface LogLayerData extends Record<string, any> {}
|
|
53
|
+
interface LogLayerCommonDataParams {
|
|
54
|
+
/**
|
|
55
|
+
* Combined object data containing the metadata, context, and / or error data in a
|
|
56
|
+
* structured format configured by the user.
|
|
57
|
+
*/
|
|
58
|
+
data?: LogLayerData;
|
|
59
|
+
/**
|
|
60
|
+
* Individual metadata object passed to the log message method.
|
|
61
|
+
*/
|
|
62
|
+
metadata?: LogLayerMetadata;
|
|
63
|
+
/**
|
|
64
|
+
* Error passed to the log message method.
|
|
65
|
+
*/
|
|
66
|
+
error?: any;
|
|
67
|
+
/**
|
|
68
|
+
* Context data that is included with each log entry.
|
|
69
|
+
*/
|
|
70
|
+
context?: LogLayerContext;
|
|
71
|
+
} //#endregion
|
|
72
|
+
//#region src/plugin.types.d.ts
|
|
73
|
+
/**
|
|
74
|
+
* Input for the `onBeforeDataOut` plugin lifecycle method.
|
|
75
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforedataout | Creating Plugins}
|
|
76
|
+
*/
|
|
77
|
+
interface PluginBeforeDataOutParams extends LogLayerCommonDataParams {
|
|
78
|
+
/**
|
|
79
|
+
* Log level of the data
|
|
80
|
+
*/
|
|
81
|
+
logLevel: LogLevelType;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Input for the `transformLogLevel` plugin lifecycle method.
|
|
85
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#transformloglevel | Creating Plugins}
|
|
86
|
+
*/
|
|
87
|
+
interface PluginTransformLogLevelParams extends LogLayerCommonDataParams {
|
|
88
|
+
/**
|
|
89
|
+
* Log level of the data
|
|
90
|
+
*/
|
|
91
|
+
logLevel: LogLevelType;
|
|
92
|
+
/**
|
|
93
|
+
* Message data that is copied from the original.
|
|
94
|
+
*/
|
|
95
|
+
messages: any[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Input for the `shouldSendToLogger` plugin lifecycle method.
|
|
99
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#shouldsendtologger | Creating Plugins}
|
|
100
|
+
*/
|
|
101
|
+
interface PluginShouldSendToLoggerParams extends LogLayerCommonDataParams {
|
|
102
|
+
/**
|
|
103
|
+
* Unique identifier for the transport. Can be used to not send to a specific transport.
|
|
104
|
+
*/
|
|
105
|
+
transportId?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Message data that is copied from the original.
|
|
108
|
+
*/
|
|
109
|
+
messages: any[];
|
|
110
|
+
/**
|
|
111
|
+
* Log level of the message
|
|
112
|
+
*/
|
|
113
|
+
logLevel: LogLevelType;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Input for the `onBeforeMessageOut` plugin lifecycle method.
|
|
117
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforemessageout | Creating Plugins}
|
|
118
|
+
*/
|
|
119
|
+
interface PluginBeforeMessageOutParams {
|
|
120
|
+
/**
|
|
121
|
+
* Log level of the message
|
|
122
|
+
*/
|
|
123
|
+
logLevel: LogLevelType;
|
|
124
|
+
/**
|
|
125
|
+
* Message data that is copied from the original.
|
|
126
|
+
*/
|
|
127
|
+
messages: any[];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Parameters for creating a LogLayer plugin.
|
|
131
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html | Creating Plugins}
|
|
132
|
+
*/
|
|
133
|
+
interface LogLayerPluginParams {
|
|
134
|
+
/**
|
|
135
|
+
* Unique identifier for the plugin. Used for selectively disabling / enabling
|
|
136
|
+
* and removing the plugin. If not defined, a randomly generated ID will be used.
|
|
137
|
+
*/
|
|
138
|
+
id?: string;
|
|
139
|
+
/**
|
|
140
|
+
* If true, the plugin will skip execution
|
|
141
|
+
*/
|
|
142
|
+
disabled?: boolean;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Interface for implementing a LogLayer plugin.
|
|
146
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html | Creating Plugins}
|
|
147
|
+
*/
|
|
148
|
+
interface LogLayerPlugin extends LogLayerPluginParams {
|
|
149
|
+
/**
|
|
150
|
+
* Called after `onBeforeDataOut` and `onBeforeMessageOut` but before `shouldSendToLogger` to transform the log level.
|
|
151
|
+
* This allows you to change the log level based on the processed log data, metadata, context, error, or messages.
|
|
152
|
+
*
|
|
153
|
+
* - The shape of `data` varies depending on your `fieldName` configuration
|
|
154
|
+
* for metadata / context / error. The metadata / context / error data is a *shallow* clone.
|
|
155
|
+
* - If data was not found for assembly, `undefined` is used as the `data` input.
|
|
156
|
+
* - The `data` parameter will contain any modifications made by `onBeforeDataOut` plugins.
|
|
157
|
+
* - The `messages` parameter will contain any modifications made by `onBeforeMessageOut` plugins.
|
|
158
|
+
* - If multiple plugins define `transformLogLevel`, the last one that returns a valid log level wins.
|
|
159
|
+
*
|
|
160
|
+
* @returns [LogLevelType] The log level to use for the log. Returning null, undefined, or false
|
|
161
|
+
* will use the log level originally specified.
|
|
162
|
+
*
|
|
163
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#transformloglevel | Creating Plugins}
|
|
164
|
+
*/
|
|
165
|
+
transformLogLevel?(params: PluginTransformLogLevelParams, loglayer: ILogLayer): LogLevelType | null | undefined | false;
|
|
166
|
+
/**
|
|
167
|
+
* Called after the assembly of the data object that contains
|
|
168
|
+
* the metadata / context / error data before being sent to the destination logging
|
|
169
|
+
* library.
|
|
170
|
+
*
|
|
171
|
+
* - The shape of `data` varies depending on your `fieldName` configuration
|
|
172
|
+
* for metadata / context / error. The metadata / context / error data is a *shallow* clone.
|
|
173
|
+
* - If data was not found for assembly, `undefined` is used as the `data` input.
|
|
174
|
+
* - You can also create your own object and return it to be sent to the logging library.
|
|
175
|
+
*
|
|
176
|
+
* @returns [Object] The object to be sent to the destination logging
|
|
177
|
+
* library or null / undefined to not pass an object through.
|
|
178
|
+
*
|
|
179
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforedataout | Creating Plugins}
|
|
180
|
+
*/
|
|
181
|
+
onBeforeDataOut?(params: PluginBeforeDataOutParams, loglayer: ILogLayer): LogLayerData | null | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Called after `onBeforeDataOut` and before `shouldSendToLogger`.
|
|
184
|
+
* This allows you to modify the message data before it is sent to the destination logging library.
|
|
185
|
+
*
|
|
186
|
+
* @returns [Array] The message data to be sent to the destination logging library.
|
|
187
|
+
*
|
|
188
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforemessageout | Creating Plugins}
|
|
189
|
+
*/
|
|
190
|
+
onBeforeMessageOut?(params: PluginBeforeMessageOutParams, loglayer: ILogLayer): any[];
|
|
191
|
+
/**
|
|
192
|
+
* Called before the data is sent to the transport. Return false to omit sending
|
|
193
|
+
* to the transport. Useful for isolating specific log messages for debugging /
|
|
194
|
+
* troubleshooting.
|
|
195
|
+
*
|
|
196
|
+
* If there are multiple plugins with shouldSendToLogger defined, the
|
|
197
|
+
* first plugin to return false will stop the data from being sent to the
|
|
198
|
+
* transport.
|
|
199
|
+
*
|
|
200
|
+
* @returns boolean If true, sends data to the transport, if false does not.
|
|
201
|
+
*
|
|
202
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#shouldsendtologger | Creating Plugins}
|
|
203
|
+
*/
|
|
204
|
+
shouldSendToLogger?(params: PluginShouldSendToLoggerParams, loglayer: ILogLayer): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Called when withMetadata() or metadataOnly() is called. This allows you to modify the metadata before it is sent to the destination logging library.
|
|
207
|
+
*
|
|
208
|
+
* The metadata is a *shallow* clone of the metadata input.
|
|
209
|
+
*
|
|
210
|
+
* If null is returned, then no metadata will be sent to the destination logging library.
|
|
211
|
+
*
|
|
212
|
+
* In multiple plugins, the modified metadata will be passed through each plugin in the order they are added.
|
|
213
|
+
*
|
|
214
|
+
* @returns [Object] The metadata object to be sent to the destination logging library.
|
|
215
|
+
*
|
|
216
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onmetadatacalled | Creating Plugins}
|
|
217
|
+
*/
|
|
218
|
+
onMetadataCalled?: (metadata: LogLayerMetadata, loglayer: ILogLayer) => LogLayerMetadata | null | undefined;
|
|
219
|
+
/**
|
|
220
|
+
* Called when withContext() is called. This allows you to modify the context before it is used.
|
|
221
|
+
*
|
|
222
|
+
* The context is a *shallow* clone of the context input.
|
|
223
|
+
*
|
|
224
|
+
* If null is returned, then no context will be used.
|
|
225
|
+
*
|
|
226
|
+
* In multiple plugins, the modified context will be passed through each plugin in the order they are added.
|
|
227
|
+
*
|
|
228
|
+
* @returns [Object] The context object to be used.
|
|
229
|
+
*
|
|
230
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#oncontextcalled | Creating Plugins}
|
|
231
|
+
*/
|
|
232
|
+
onContextCalled?: (context: LogLayerContext, loglayer: ILogLayer) => LogLayerContext | null | undefined;
|
|
233
|
+
} //#endregion
|
|
234
|
+
//#region src/loglayer.types.d.ts
|
|
235
|
+
/**
|
|
236
|
+
* Interface for raw log entries that allows complete control over all aspects of a log entry.
|
|
237
|
+
*
|
|
238
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#raw-logging | Raw Logging Documentation}
|
|
239
|
+
*/
|
|
240
|
+
interface RawLogEntry {
|
|
241
|
+
/**
|
|
242
|
+
* Context data to include with the log entry.
|
|
243
|
+
*
|
|
244
|
+
* - When provided, this context data will be used instead of the context manager.
|
|
245
|
+
* - If not provided, the context manager data will be used instead
|
|
246
|
+
* - An empty object will result in no context data being used at all
|
|
247
|
+
*/
|
|
248
|
+
context?: LogLayerContext;
|
|
249
|
+
/**
|
|
250
|
+
* Metadata to include with the log entry.
|
|
251
|
+
*/
|
|
252
|
+
metadata?: LogLayerMetadata;
|
|
253
|
+
/**
|
|
254
|
+
* Error object to include with the log entry.
|
|
255
|
+
*/
|
|
256
|
+
error?: any;
|
|
257
|
+
/**
|
|
258
|
+
* The log level for this entry.
|
|
259
|
+
*/
|
|
260
|
+
logLevel: LogLevelType;
|
|
261
|
+
/**
|
|
262
|
+
* Array of message parameters to log.
|
|
263
|
+
*
|
|
264
|
+
* These are the actual log messages and can include strings, numbers,
|
|
265
|
+
* booleans, null, or undefined values. The first string message will
|
|
266
|
+
* have any configured prefix applied to it.
|
|
267
|
+
*/
|
|
268
|
+
messages?: MessageDataType[];
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Context Manager callback function for when a child logger is created.
|
|
272
|
+
* @see {@link https://loglayer.dev/context-managers/creating-context-managers.html | Creating Context Managers Docs}
|
|
273
|
+
*/
|
|
274
|
+
interface OnChildLoggerCreatedParams {
|
|
275
|
+
/**
|
|
276
|
+
* The parent logger instance
|
|
277
|
+
*/
|
|
278
|
+
parentLogger: ILogLayer<any>;
|
|
279
|
+
/**
|
|
280
|
+
* The child logger instance
|
|
281
|
+
*/
|
|
282
|
+
childLogger: ILogLayer<any>;
|
|
283
|
+
/**
|
|
284
|
+
* The parent logger's context manager
|
|
285
|
+
*/
|
|
286
|
+
parentContextManager: IContextManager;
|
|
287
|
+
/**
|
|
288
|
+
* The child logger's context manager
|
|
289
|
+
*/
|
|
290
|
+
childContextManager: IContextManager;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Interface for implementing a context manager instance.
|
|
294
|
+
*
|
|
295
|
+
* If your context manager needs to clean up resources (like file handles, memory, or external connections),
|
|
296
|
+
* you can optionally implement the {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management | Disposable} interface.
|
|
297
|
+
* LogLayer will automatically call the dispose method when the context manager is replaced using `withContextManager()`.
|
|
298
|
+
*
|
|
299
|
+
* @see {@link https://loglayer.dev/context-managers/creating-context-managers.html | Creating Context Managers Docs}
|
|
300
|
+
*/
|
|
301
|
+
interface IContextManager {
|
|
302
|
+
/**
|
|
303
|
+
* Sets the context data to be included with every log entry. Set to `undefined` to clear the context data.
|
|
304
|
+
*/
|
|
305
|
+
setContext(context?: LogLayerContext): void;
|
|
306
|
+
/**
|
|
307
|
+
* Appends context data to the existing context data.
|
|
308
|
+
*/
|
|
309
|
+
appendContext(context: Partial<LogLayerContext>): void;
|
|
310
|
+
/**
|
|
311
|
+
* Returns the context data to be included with every log entry.
|
|
312
|
+
*/
|
|
313
|
+
getContext(): LogLayerContext;
|
|
314
|
+
/**
|
|
315
|
+
* Returns true if context data is present.
|
|
316
|
+
*/
|
|
317
|
+
hasContextData(): boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Clears the context data. If keys are provided, only those keys will be removed.
|
|
320
|
+
* If no keys are provided, all context data will be cleared.
|
|
321
|
+
*/
|
|
322
|
+
clearContext(keys?: string | string[]): void;
|
|
323
|
+
/**
|
|
324
|
+
* Called when a child logger is created. Use to manipulate context data between parent and child.
|
|
325
|
+
*/
|
|
326
|
+
onChildLoggerCreated(params: OnChildLoggerCreatedParams): void;
|
|
327
|
+
/**
|
|
328
|
+
* Creates a new instance of the context manager with the same context data.
|
|
329
|
+
*/
|
|
330
|
+
clone(): IContextManager;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Log Level Manager callback function for when a child logger is created.
|
|
334
|
+
*/
|
|
335
|
+
interface OnChildLogLevelManagerCreatedParams {
|
|
336
|
+
/**
|
|
337
|
+
* The parent logger instance
|
|
338
|
+
*/
|
|
339
|
+
parentLogger: ILogLayer<any>;
|
|
340
|
+
/**
|
|
341
|
+
* The child logger instance
|
|
342
|
+
*/
|
|
343
|
+
childLogger: ILogLayer<any>;
|
|
344
|
+
/**
|
|
345
|
+
* The parent logger's log level manager
|
|
346
|
+
*/
|
|
347
|
+
parentLogLevelManager: ILogLevelManager;
|
|
348
|
+
/**
|
|
349
|
+
* The child logger's log level manager
|
|
350
|
+
*/
|
|
351
|
+
childLogLevelManager: ILogLevelManager;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Interface for implementing a log level manager instance.
|
|
355
|
+
*
|
|
356
|
+
* Log level managers are responsible for managing log level settings across logger instances.
|
|
357
|
+
* They control how log levels are inherited and propagated between parent and child loggers.
|
|
358
|
+
*
|
|
359
|
+
* If your log level manager needs to clean up resources (like parent-child references, memory, or external connections),
|
|
360
|
+
* you can optionally implement the {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management | Disposable} interface.
|
|
361
|
+
* LogLayer will automatically call the dispose method when the log level manager is replaced using `withLogLevelManager()`.
|
|
362
|
+
*
|
|
363
|
+
* @see {@link https://loglayer.dev/log-level-managers/creating-log-level-managers.html | Creating Log Level Managers Docs}
|
|
364
|
+
*/
|
|
365
|
+
interface ILogLevelManager {
|
|
366
|
+
/**
|
|
367
|
+
* Sets the minimum log level to be used by the logger. Only messages with
|
|
368
|
+
* this level or higher severity will be logged.
|
|
369
|
+
*
|
|
370
|
+
* **When triggered:** Called when `logger.setLevel()` is invoked on a LogLayer instance.
|
|
371
|
+
*/
|
|
372
|
+
setLevel(logLevel: LogLevelType): void;
|
|
373
|
+
/**
|
|
374
|
+
* Enables a specific log level.
|
|
375
|
+
*
|
|
376
|
+
* **When triggered:** Called when `logger.enableIndividualLevel()` is invoked on a LogLayer instance.
|
|
377
|
+
*/
|
|
378
|
+
enableIndividualLevel(logLevel: LogLevelType): void;
|
|
379
|
+
/**
|
|
380
|
+
* Disables a specific log level.
|
|
381
|
+
*
|
|
382
|
+
* **When triggered:** Called when `logger.disableIndividualLevel()` is invoked on a LogLayer instance.
|
|
383
|
+
*/
|
|
384
|
+
disableIndividualLevel(logLevel: LogLevelType): void;
|
|
385
|
+
/**
|
|
386
|
+
* Checks if a specific log level is enabled.
|
|
387
|
+
*
|
|
388
|
+
* **When triggered:** Called before every log method execution (e.g., `info()`, `warn()`, `error()`, `debug()`, `trace()`, `fatal()`, `raw()`, `metadataOnly()`, `errorOnly()`) to determine if the log should be processed. Also called when `logger.isLevelEnabled()` is invoked directly.
|
|
389
|
+
*/
|
|
390
|
+
isLevelEnabled(logLevel: LogLevelType): boolean;
|
|
391
|
+
/**
|
|
392
|
+
* Enable sending logs to the logging library.
|
|
393
|
+
*
|
|
394
|
+
* **When triggered:** Called when `logger.enableLogging()` is invoked on a LogLayer instance.
|
|
395
|
+
*/
|
|
396
|
+
enableLogging(): void;
|
|
397
|
+
/**
|
|
398
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
399
|
+
*
|
|
400
|
+
* **When triggered:** Called when `logger.disableLogging()` is invoked on a LogLayer instance, or when a LogLayer instance is created with `enabled: false` in the configuration.
|
|
401
|
+
*/
|
|
402
|
+
disableLogging(): void;
|
|
403
|
+
/**
|
|
404
|
+
* Called when a child logger is created. Use to manipulate log level settings between parent and child.
|
|
405
|
+
*
|
|
406
|
+
* **When triggered:** Called automatically when `logger.child()` is invoked, after the child logger is created and the parent's log level manager has been cloned. This allows the manager to establish relationships between parent and child loggers.
|
|
407
|
+
*/
|
|
408
|
+
onChildLoggerCreated(params: OnChildLogLevelManagerCreatedParams): void;
|
|
409
|
+
/**
|
|
410
|
+
* Creates a new instance of the log level manager with the same log level settings.
|
|
411
|
+
*
|
|
412
|
+
* **When triggered:** Called automatically when `logger.child()` is invoked to create a new log level manager instance for the child logger. The cloned instance should have the same initial log level state as the parent, but can be modified independently (unless the manager implements shared state behavior).
|
|
413
|
+
*/
|
|
414
|
+
clone(): ILogLevelManager;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Input to the LogLayer transport shipToLogger() method.
|
|
418
|
+
* @see {@link https://loglayer.dev/transports/creating-transports.html | Creating Transports Docs}
|
|
419
|
+
*/
|
|
420
|
+
interface LogLayerTransportParams extends LogLayerCommonDataParams {
|
|
421
|
+
/**
|
|
422
|
+
* The log level of the message
|
|
423
|
+
*/
|
|
424
|
+
logLevel: LogLevelType;
|
|
425
|
+
/**
|
|
426
|
+
* The parameters that were passed to the log message method (eg: info / warn / debug / error)
|
|
427
|
+
*/
|
|
428
|
+
messages: any[];
|
|
429
|
+
/**
|
|
430
|
+
* If true, the data object is included in the message parameters
|
|
431
|
+
*/
|
|
432
|
+
hasData?: boolean;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Interface for implementing a LogLayer transport instance.
|
|
436
|
+
* @see {@link https://loglayer.dev/transports/creating-transports.html | Creating Transports Docs}
|
|
437
|
+
*/
|
|
438
|
+
interface LogLayerTransport<LogLibrary = any> {
|
|
439
|
+
/**
|
|
440
|
+
* A user-defined identifier for the transport
|
|
441
|
+
**/
|
|
442
|
+
id?: string;
|
|
443
|
+
/**
|
|
444
|
+
* If false, the transport will not send logs to the logger.
|
|
445
|
+
* Default is true.
|
|
446
|
+
*/
|
|
447
|
+
enabled?: boolean;
|
|
448
|
+
/**
|
|
449
|
+
* Sends the log data to the logger for transport
|
|
450
|
+
*/
|
|
451
|
+
shipToLogger(params: LogLayerTransportParams): any[];
|
|
452
|
+
/**
|
|
453
|
+
* Internal use only. Do not implement.
|
|
454
|
+
* @param params
|
|
455
|
+
*/
|
|
456
|
+
_sendToLogger(params: LogLayerTransportParams): void;
|
|
457
|
+
/**
|
|
458
|
+
* Returns the logger instance attached to the transport
|
|
459
|
+
*/
|
|
460
|
+
getLoggerInstance(): LogLibrary;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Interface for implementing a LogLayer builder instance.
|
|
464
|
+
* @see {@link https://loglayer.dev | LogLayer Documentation}
|
|
465
|
+
*/
|
|
466
|
+
interface ILogBuilder<This = ILogBuilder<any>> {
|
|
467
|
+
/**
|
|
468
|
+
* Sends a log message to the logging library under an info log level.
|
|
469
|
+
*/
|
|
470
|
+
info(...messages: MessageDataType[]): void;
|
|
471
|
+
/**
|
|
472
|
+
* Sends a log message to the logging library under the warn log level
|
|
473
|
+
*/
|
|
474
|
+
warn(...messages: MessageDataType[]): void;
|
|
475
|
+
/**
|
|
476
|
+
* Sends a log message to the logging library under the error log level
|
|
477
|
+
*/
|
|
478
|
+
error(...messages: MessageDataType[]): void;
|
|
479
|
+
/**
|
|
480
|
+
* Sends a log message to the logging library under the debug log level
|
|
481
|
+
*/
|
|
482
|
+
debug(...messages: MessageDataType[]): void;
|
|
483
|
+
/**
|
|
484
|
+
* Sends a log message to the logging library under the trace log level
|
|
485
|
+
*/
|
|
486
|
+
trace(...messages: MessageDataType[]): void;
|
|
487
|
+
/**
|
|
488
|
+
* Sends a log message to the logging library under the fatal log level
|
|
489
|
+
*/
|
|
490
|
+
fatal(...messages: MessageDataType[]): void;
|
|
491
|
+
/**
|
|
492
|
+
* Specifies metadata to include with the log message
|
|
493
|
+
*
|
|
494
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html | Metadata Docs}
|
|
495
|
+
*/
|
|
496
|
+
withMetadata(metadata?: LogLayerMetadata): This;
|
|
497
|
+
/**
|
|
498
|
+
* Specifies an Error to include with the log message
|
|
499
|
+
*
|
|
500
|
+
* @see {@link https://loglayer.dev/logging-api/error-handling.html | Error Handling Docs}
|
|
501
|
+
*/
|
|
502
|
+
withError(error: any): This;
|
|
503
|
+
/**
|
|
504
|
+
* Enable sending logs to the logging library.
|
|
505
|
+
*
|
|
506
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
507
|
+
*/
|
|
508
|
+
enableLogging(): This;
|
|
509
|
+
/**
|
|
510
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
511
|
+
*
|
|
512
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
513
|
+
*/
|
|
514
|
+
disableLogging(): This;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Interface for implementing a LogLayer logger instance.
|
|
518
|
+
* @see {@link https://loglayer.dev | LogLayer Documentation}
|
|
519
|
+
*/
|
|
520
|
+
interface ILogLayer<This = ILogLayer<any>> {
|
|
521
|
+
/**
|
|
522
|
+
* Sends a log message to the logging library under an info log level.
|
|
523
|
+
*/
|
|
524
|
+
info(...messages: MessageDataType[]): void;
|
|
525
|
+
/**
|
|
526
|
+
* Sends a log message to the logging library under the warn log level
|
|
527
|
+
*/
|
|
528
|
+
warn(...messages: MessageDataType[]): void;
|
|
529
|
+
/**
|
|
530
|
+
* Sends a log message to the logging library under the error log level
|
|
531
|
+
*/
|
|
532
|
+
error(...messages: MessageDataType[]): void;
|
|
533
|
+
/**
|
|
534
|
+
* Sends a log message to the logging library under the debug log level
|
|
535
|
+
*/
|
|
536
|
+
debug(...messages: MessageDataType[]): void;
|
|
537
|
+
/**
|
|
538
|
+
* Sends a log message to the logging library under the trace log level
|
|
539
|
+
*/
|
|
540
|
+
trace(...messages: MessageDataType[]): void;
|
|
541
|
+
/**
|
|
542
|
+
* Sends a log message to the logging library under the fatal log level
|
|
543
|
+
*/
|
|
544
|
+
fatal(...messages: MessageDataType[]): void;
|
|
545
|
+
/**
|
|
546
|
+
* Specifies metadata to include with the log message
|
|
547
|
+
*
|
|
548
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html | Metadata Docs}
|
|
549
|
+
*/
|
|
550
|
+
withMetadata(metadata?: LogLayerMetadata): ILogBuilder<any>;
|
|
551
|
+
/**
|
|
552
|
+
* Specifies an Error to include with the log message
|
|
553
|
+
*
|
|
554
|
+
* @see {@link https://loglayer.dev/logging-api/error-handling.html | Error Handling Docs}
|
|
555
|
+
*/
|
|
556
|
+
withError(error: any): ILogBuilder<any>;
|
|
557
|
+
/**
|
|
558
|
+
* Enable sending logs to the logging library.
|
|
559
|
+
*
|
|
560
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
561
|
+
*/
|
|
562
|
+
enableLogging(): This;
|
|
563
|
+
/**
|
|
564
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
565
|
+
*
|
|
566
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
567
|
+
*/
|
|
568
|
+
disableLogging(): This;
|
|
569
|
+
/**
|
|
570
|
+
* Calls child() and sets the prefix to be included with every log message.
|
|
571
|
+
*
|
|
572
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#message-prefixing | Message Prefixing Docs}
|
|
573
|
+
*/
|
|
574
|
+
withPrefix(string: string): This;
|
|
575
|
+
/**
|
|
576
|
+
* Appends context data which will be included with
|
|
577
|
+
* every log entry.
|
|
578
|
+
*
|
|
579
|
+
* Passing in an empty value / object will *not* clear the context.
|
|
580
|
+
*
|
|
581
|
+
* To clear the context, use {@link clearContext}.
|
|
582
|
+
*
|
|
583
|
+
* @see {@link https://loglayer.dev/logging-api/context.html | Context Docs}
|
|
584
|
+
*/
|
|
585
|
+
withContext(context?: LogLayerContext): This;
|
|
586
|
+
/**
|
|
587
|
+
* Clears the context data. If keys are provided, only those keys will be removed.
|
|
588
|
+
* If no keys are provided, all context data will be cleared.
|
|
589
|
+
*
|
|
590
|
+
* @see {@link https://loglayer.dev/logging-api/context.html | Context Docs}
|
|
591
|
+
*/
|
|
592
|
+
clearContext(keys?: string | string[]): This;
|
|
593
|
+
/**
|
|
594
|
+
* Logs only the error object without a log message
|
|
595
|
+
*
|
|
596
|
+
* @see {@link https://loglayer.dev/logging-api/error-handling.html | Error Handling Docs}
|
|
597
|
+
*/
|
|
598
|
+
errorOnly(error: any, opts?: ErrorOnlyOpts): void;
|
|
599
|
+
/**
|
|
600
|
+
* Logs only metadata without a log message
|
|
601
|
+
*
|
|
602
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html | Metadata Docs}
|
|
603
|
+
*/
|
|
604
|
+
metadataOnly(metadata?: LogLayerMetadata, logLevel?: LogLevelType): void;
|
|
605
|
+
/**
|
|
606
|
+
* Returns the context used
|
|
607
|
+
*
|
|
608
|
+
* @see {@link https://loglayer.dev/logging-api/context.html | Context Docs}
|
|
609
|
+
*/
|
|
610
|
+
getContext(): LogLayerContext;
|
|
611
|
+
/**
|
|
612
|
+
* Creates a new instance of LogLayer but with the initialization
|
|
613
|
+
* configuration and context data copied over.
|
|
614
|
+
*
|
|
615
|
+
* The copied context data is a *shallow copy*.
|
|
616
|
+
*
|
|
617
|
+
* @see {@link https://loglayer.dev/logging-api/child-loggers.html | Child Logging Docs}
|
|
618
|
+
*/
|
|
619
|
+
child(): This;
|
|
620
|
+
/**
|
|
621
|
+
* Disables inclusion of context data in the print
|
|
622
|
+
*
|
|
623
|
+
* @see {@link https://loglayer.dev/logging-api/context.html#managing-context | Managing Context Docs}
|
|
624
|
+
*/
|
|
625
|
+
muteContext(): This;
|
|
626
|
+
/**
|
|
627
|
+
* Enables inclusion of context data in the print
|
|
628
|
+
*
|
|
629
|
+
* @see {@link https://loglayer.dev/logging-api/context.html#managing-context | Managing Context Docs}
|
|
630
|
+
*/
|
|
631
|
+
unMuteContext(): This;
|
|
632
|
+
/**
|
|
633
|
+
* Disables inclusion of metadata data in the print
|
|
634
|
+
*
|
|
635
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html#controlling-metadata-output | Controlling Metadata Output Docs}
|
|
636
|
+
*/
|
|
637
|
+
muteMetadata(): This;
|
|
638
|
+
/**
|
|
639
|
+
* Enables inclusion of metadata data in the print
|
|
640
|
+
*
|
|
641
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html#controlling-metadata-output | Controlling Metadata Output Docs}
|
|
642
|
+
*/
|
|
643
|
+
unMuteMetadata(): This;
|
|
644
|
+
/**
|
|
645
|
+
* Enables a specific log level
|
|
646
|
+
*
|
|
647
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
648
|
+
*/
|
|
649
|
+
enableIndividualLevel(logLevel: LogLevelType): This;
|
|
650
|
+
/**
|
|
651
|
+
* Disables a specific log level
|
|
652
|
+
*
|
|
653
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
654
|
+
*/
|
|
655
|
+
disableIndividualLevel(logLevel: LogLevelType): This;
|
|
656
|
+
/**
|
|
657
|
+
* Sets the minimum log level to be used by the logger. Only messages with
|
|
658
|
+
* this level or higher severity will be logged.
|
|
659
|
+
*
|
|
660
|
+
* For example, if you setLevel(LogLevel.warn), this will:
|
|
661
|
+
* Enable:
|
|
662
|
+
* - warn
|
|
663
|
+
* - error
|
|
664
|
+
* - fatal
|
|
665
|
+
* Disable:
|
|
666
|
+
* - info
|
|
667
|
+
* - debug
|
|
668
|
+
* - trace
|
|
669
|
+
*
|
|
670
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
671
|
+
*/
|
|
672
|
+
setLevel(logLevel: LogLevelType): This;
|
|
673
|
+
/**
|
|
674
|
+
* Checks if a specific log level is enabled
|
|
675
|
+
*
|
|
676
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#checking-if-a-log-level-is-enabled | Checking if a Log Level is Enabled Docs}
|
|
677
|
+
*/
|
|
678
|
+
isLevelEnabled(logLevel: LogLevelType): boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Enable sending logs to the logging library.
|
|
681
|
+
*
|
|
682
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
683
|
+
*/
|
|
684
|
+
enableLogging(): This;
|
|
685
|
+
/**
|
|
686
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
687
|
+
*
|
|
688
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
689
|
+
*/
|
|
690
|
+
disableLogging(): This;
|
|
691
|
+
/**
|
|
692
|
+
* Returns a logger instance for a specific transport
|
|
693
|
+
*
|
|
694
|
+
* @see {@link https://loglayer.dev/logging-api/transport-management.html | Transport Management Docs}
|
|
695
|
+
*/
|
|
696
|
+
getLoggerInstance<Library>(id: string): Library | undefined;
|
|
697
|
+
/**
|
|
698
|
+
* Replaces all existing transports with new ones while preserving other logger configuration.
|
|
699
|
+
*
|
|
700
|
+
* Transport changes only affect the current logger instance. Child loggers
|
|
701
|
+
* created before the change will retain their original transports, and
|
|
702
|
+
* parent loggers are not affected when a child modifies its transports.
|
|
703
|
+
*
|
|
704
|
+
* @see {@link https://loglayer.dev/logging-api/transport-management.html | Transport Management Docs}
|
|
705
|
+
*/
|
|
706
|
+
withFreshTransports(transports: LogLayerTransport | Array<LogLayerTransport>): This;
|
|
707
|
+
/**
|
|
708
|
+
* Adds one or more transports to the existing transports.
|
|
709
|
+
* If a transport with the same ID already exists, it will be replaced.
|
|
710
|
+
*
|
|
711
|
+
* Transport changes only affect the current logger instance. Child loggers
|
|
712
|
+
* created before the change will retain their original transports, and
|
|
713
|
+
* parent loggers are not affected when a child modifies its transports.
|
|
714
|
+
*
|
|
715
|
+
* @see {@link https://loglayer.dev/logging-api/transport-management.html | Transport Management Docs}
|
|
716
|
+
*/
|
|
717
|
+
addTransport(transports: LogLayerTransport | Array<LogLayerTransport>): This;
|
|
718
|
+
/**
|
|
719
|
+
* Removes a transport by its ID.
|
|
720
|
+
*
|
|
721
|
+
* Transport changes only affect the current logger instance. Child loggers
|
|
722
|
+
* created before the change will retain their original transports, and
|
|
723
|
+
* parent loggers are not affected when a child modifies its transports.
|
|
724
|
+
*
|
|
725
|
+
* @returns true if the transport was found and removed, false otherwise.
|
|
726
|
+
*
|
|
727
|
+
* @see {@link https://loglayer.dev/logging-api/transport-management.html | Transport Management Docs}
|
|
728
|
+
*/
|
|
729
|
+
removeTransport(id: string): boolean;
|
|
730
|
+
/**
|
|
731
|
+
* Replaces all existing plugins with new ones.
|
|
732
|
+
*
|
|
733
|
+
* When used with child loggers, it only affects the current logger instance
|
|
734
|
+
* and does not modify the parent's plugins.
|
|
735
|
+
*
|
|
736
|
+
* @see {@link https://loglayer.dev/plugins/ | Plugins Docs}
|
|
737
|
+
*/
|
|
738
|
+
withFreshPlugins(plugins: Array<LogLayerPlugin>): This;
|
|
739
|
+
/**
|
|
740
|
+
* Sets the context manager to use for managing context data.
|
|
741
|
+
*/
|
|
742
|
+
withContextManager(manager: IContextManager): This;
|
|
743
|
+
/**
|
|
744
|
+
* Gets the context manager used by the logger.
|
|
745
|
+
*/
|
|
746
|
+
getContextManager<M extends IContextManager = IContextManager>(): M;
|
|
747
|
+
/**
|
|
748
|
+
* Sets the log level manager to use for managing log levels.
|
|
749
|
+
*/
|
|
750
|
+
withLogLevelManager(manager: ILogLevelManager): This;
|
|
751
|
+
/**
|
|
752
|
+
* Gets the log level manager used by the logger.
|
|
753
|
+
*/
|
|
754
|
+
getLogLevelManager<M extends ILogLevelManager = ILogLevelManager>(): M;
|
|
755
|
+
/**
|
|
756
|
+
* Returns the configuration object used to initialize the logger.
|
|
757
|
+
*/
|
|
758
|
+
getConfig(): {
|
|
759
|
+
prefix?: string;
|
|
760
|
+
enabled?: boolean;
|
|
761
|
+
consoleDebug?: boolean;
|
|
762
|
+
transport: LogLayerTransport | Array<LogLayerTransport>;
|
|
763
|
+
plugins?: Array<LogLayerPlugin>;
|
|
764
|
+
errorSerializer?: (err: any) => Record<string, any> | string;
|
|
765
|
+
errorFieldName?: string;
|
|
766
|
+
copyMsgOnOnlyError?: boolean;
|
|
767
|
+
errorFieldInMetadata?: boolean;
|
|
768
|
+
contextFieldName?: string;
|
|
769
|
+
metadataFieldName?: string;
|
|
770
|
+
muteContext?: boolean;
|
|
771
|
+
muteMetadata?: boolean;
|
|
772
|
+
};
|
|
773
|
+
/**
|
|
774
|
+
* Logs a raw log entry with complete control over all log parameters.
|
|
775
|
+
*
|
|
776
|
+
* This method allows you to bypass the normal LogLayer API and directly specify
|
|
777
|
+
* all aspects of a log entry including log level, messages, metadata, and error.
|
|
778
|
+
* It's useful for scenarios where you need to log structured data that doesn't
|
|
779
|
+
* fit the standard LogLayer patterns, or when integrating with external logging
|
|
780
|
+
* systems that provide pre-formatted log entries.
|
|
781
|
+
*
|
|
782
|
+
* The raw entry will still go through all LogLayer processing.
|
|
783
|
+
*
|
|
784
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html | Basic Logging Docs}
|
|
785
|
+
*/
|
|
786
|
+
raw(rawEntry: RawLogEntry): void;
|
|
787
|
+
} //#endregion
|
|
788
|
+
//#endregion
|
|
789
|
+
//#region ../../core/plugin/dist/index.d.ts
|
|
790
|
+
/**
|
|
791
|
+
* List of plugin callbacks that can be called by the plugin manager.
|
|
792
|
+
*
|
|
793
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#transformloglevel | transformLogLevel Docs}
|
|
794
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforedataout | onBeforeDataOut Docs}
|
|
795
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#shouldsendtologger | shouldSendToLogger Docs}
|
|
796
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onmetadatacalled | onMetadataCalled Docs}
|
|
797
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforemessageout | onBeforeMessageOut Docs}
|
|
798
|
+
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#oncontextcalled | onContextCalled Docs}
|
|
799
|
+
*/
|
|
800
|
+
declare enum PluginCallbackType {
|
|
801
|
+
transformLogLevel = "transformLogLevel",
|
|
802
|
+
onBeforeDataOut = "onBeforeDataOut",
|
|
803
|
+
shouldSendToLogger = "shouldSendToLogger",
|
|
804
|
+
onMetadataCalled = "onMetadataCalled",
|
|
805
|
+
onBeforeMessageOut = "onBeforeMessageOut",
|
|
806
|
+
onContextCalled = "onContextCalled"
|
|
807
|
+
} //#endregion
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region ../../core/loglayer/dist/index.d.ts
|
|
810
|
+
//#region src/PluginManager.d.ts
|
|
811
|
+
/**
|
|
812
|
+
* A class that manages plugins and runs their callbacks.
|
|
813
|
+
* Used by LogLayer to run plugins at various stages of the logging process.
|
|
814
|
+
*/
|
|
815
|
+
declare class PluginManager {
|
|
816
|
+
private idToPlugin;
|
|
817
|
+
private transformLogLevel;
|
|
818
|
+
private onBeforeDataOut;
|
|
819
|
+
private shouldSendToLogger;
|
|
820
|
+
private onMetadataCalled;
|
|
821
|
+
private onBeforeMessageOut;
|
|
822
|
+
private onContextCalled;
|
|
823
|
+
constructor(plugins: Array<LogLayerPlugin>);
|
|
824
|
+
private mapPlugins;
|
|
825
|
+
private indexPlugins;
|
|
826
|
+
hasPlugins(callbackType: PluginCallbackType): boolean;
|
|
827
|
+
countPlugins(callbackType?: PluginCallbackType): number;
|
|
828
|
+
addPlugins(plugins: Array<LogLayerPlugin>): void;
|
|
829
|
+
enablePlugin(id: string): void;
|
|
830
|
+
disablePlugin(id: string): void;
|
|
831
|
+
removePlugin(id: string): void;
|
|
832
|
+
/**
|
|
833
|
+
* Runs plugins that define transformLogLevel. Returns the transformed log level or the original if no transformation is applied.
|
|
834
|
+
* If multiple plugins transform the log level, the last one wins.
|
|
835
|
+
*/
|
|
836
|
+
runTransformLogLevel(params: PluginTransformLogLevelParams, loglayer: ILogLayer): LogLevelType;
|
|
837
|
+
/**
|
|
838
|
+
* Runs plugins that defines onBeforeDataOut.
|
|
839
|
+
*/
|
|
840
|
+
runOnBeforeDataOut(params: PluginBeforeDataOutParams, loglayer: ILogLayer): LogLayerData | undefined;
|
|
841
|
+
/**
|
|
842
|
+
* Runs plugins that define shouldSendToLogger. Any plugin that returns false will prevent the message from being sent to the transport.
|
|
843
|
+
*/
|
|
844
|
+
runShouldSendToLogger(params: PluginShouldSendToLoggerParams, loglayer: ILogLayer): boolean;
|
|
845
|
+
/**
|
|
846
|
+
* Runs plugins that define onMetadataCalled.
|
|
847
|
+
*/
|
|
848
|
+
runOnMetadataCalled(metadata: LogLayerMetadata, loglayer: ILogLayer): LogLayerMetadata | null;
|
|
849
|
+
runOnBeforeMessageOut(params: PluginBeforeMessageOutParams, loglayer: ILogLayer): MessageDataType[];
|
|
850
|
+
/**
|
|
851
|
+
* Runs plugins that define onContextCalled.
|
|
852
|
+
*/
|
|
853
|
+
runOnContextCalled(context: Record<string, any>, loglayer: ILogLayer): Record<string, any> | null;
|
|
854
|
+
} //#endregion
|
|
855
|
+
//#region src/MockLogBuilder.d.ts
|
|
856
|
+
/**
|
|
857
|
+
* A mock implementation of the ILogBuilder interface that does nothing.
|
|
858
|
+
* Useful for writing unit tests.
|
|
859
|
+
*/
|
|
860
|
+
declare class MockLogBuilder implements ILogBuilder<MockLogBuilder> {
|
|
861
|
+
debug(..._messages: MessageDataType[]): void;
|
|
862
|
+
error(..._messages: MessageDataType[]): void;
|
|
863
|
+
info(..._messages: MessageDataType[]): void;
|
|
864
|
+
trace(..._messages: MessageDataType[]): void;
|
|
865
|
+
warn(..._messages: MessageDataType[]): void;
|
|
866
|
+
fatal(..._messages: MessageDataType[]): void;
|
|
867
|
+
enableLogging(): this;
|
|
868
|
+
disableLogging(): this;
|
|
869
|
+
withMetadata(_metadata?: Record<string, any>): this;
|
|
870
|
+
withError(_error: any): this;
|
|
871
|
+
} //#endregion
|
|
872
|
+
//#region src/MockLogLayer.d.ts
|
|
873
|
+
/**
|
|
874
|
+
* A mock implementation of the ILogLayer interface that does nothing.
|
|
875
|
+
* Useful for writing unit tests.
|
|
876
|
+
* MockLogLayer implements both ILogLayer and ILogBuilder for simplicity in testing.
|
|
877
|
+
*/
|
|
878
|
+
declare class MockLogLayer$1 implements ILogLayer<MockLogLayer$1>, ILogBuilder<MockLogLayer$1> {
|
|
879
|
+
private mockLogBuilder;
|
|
880
|
+
private mockContextManager;
|
|
881
|
+
private mockLogLevelManager;
|
|
882
|
+
info(..._messages: MessageDataType[]): void;
|
|
883
|
+
warn(..._messages: MessageDataType[]): void;
|
|
884
|
+
error(..._messages: MessageDataType[]): void;
|
|
885
|
+
debug(..._messages: MessageDataType[]): void;
|
|
886
|
+
trace(..._messages: MessageDataType[]): void;
|
|
887
|
+
fatal(..._messages: MessageDataType[]): void;
|
|
888
|
+
raw(_rawEntry: RawLogEntry): void;
|
|
889
|
+
getLoggerInstance<_T extends LogLayerTransport>(_id: string): any;
|
|
890
|
+
errorOnly(_error: any, _opts?: ErrorOnlyOpts): void;
|
|
891
|
+
metadataOnly(_metadata?: Record<string, any>, _logLevel?: LogLevel): void;
|
|
892
|
+
addPlugins(_plugins: Array<LogLayerPlugin>): void;
|
|
893
|
+
removePlugin(_id: string): void;
|
|
894
|
+
enablePlugin(_id: string): void;
|
|
895
|
+
disablePlugin(_id: string): void;
|
|
896
|
+
withPrefix(_prefix: string): this;
|
|
897
|
+
withContext(_context?: Record<string, any>): this;
|
|
898
|
+
withError(_error: any): any;
|
|
899
|
+
withMetadata(_metadata?: Record<string, any>): any;
|
|
900
|
+
getContext(): Record<string, any>;
|
|
901
|
+
clearContext(_keys?: string | string[]): this;
|
|
902
|
+
enableLogging(): this;
|
|
903
|
+
disableLogging(): this;
|
|
904
|
+
child(): this;
|
|
905
|
+
muteContext(): this;
|
|
906
|
+
unMuteContext(): this;
|
|
907
|
+
muteMetadata(): this;
|
|
908
|
+
unMuteMetadata(): this;
|
|
909
|
+
withFreshTransports(_transports: LogLayerTransport | Array<LogLayerTransport>): this;
|
|
910
|
+
addTransport(_transports: LogLayerTransport | Array<LogLayerTransport>): this;
|
|
911
|
+
removeTransport(_id: string): boolean;
|
|
912
|
+
withFreshPlugins(_plugins: Array<LogLayerPlugin>): this;
|
|
913
|
+
withContextManager(_contextManager: any): this;
|
|
914
|
+
getContextManager<M extends IContextManager = IContextManager>(): M;
|
|
915
|
+
withLogLevelManager(_logLevelManager: ILogLevelManager): this;
|
|
916
|
+
getLogLevelManager<M extends ILogLevelManager = ILogLevelManager>(): M;
|
|
917
|
+
getConfig(): any;
|
|
918
|
+
/**
|
|
919
|
+
* Sets the mock log builder to use for testing.
|
|
920
|
+
*/
|
|
921
|
+
setMockLogBuilder(mockLogBuilder: ILogBuilder): void;
|
|
922
|
+
enableIndividualLevel(_logLevel: LogLevelType): this;
|
|
923
|
+
disableIndividualLevel(_logLevel: LogLevelType): this;
|
|
924
|
+
setLevel(_logLevel: LogLevelType): this;
|
|
925
|
+
isLevelEnabled(_logLevel: LogLevelType): boolean;
|
|
926
|
+
/**
|
|
927
|
+
* Returns the mock log builder used for testing.
|
|
928
|
+
*/
|
|
929
|
+
getMockLogBuilder(): ILogBuilder<ILogBuilder<any>>;
|
|
930
|
+
/**
|
|
931
|
+
* Resets the mock log builder to a new instance of MockLogBuilder.
|
|
932
|
+
*/
|
|
933
|
+
resetMockLogBuilder(): void;
|
|
934
|
+
} //#endregion
|
|
935
|
+
//#region src/types/mixin.types.d.ts
|
|
936
|
+
/**
|
|
937
|
+
* The class that the mixin extends
|
|
938
|
+
*/
|
|
939
|
+
declare enum LogLayerMixinAugmentType {
|
|
940
|
+
/**
|
|
941
|
+
* Mixin extends the LogBuilder prototype
|
|
942
|
+
*/
|
|
943
|
+
LogBuilder = "LogBuilder",
|
|
944
|
+
/**
|
|
945
|
+
* Mixin extends the LogLayer prototype
|
|
946
|
+
*/
|
|
947
|
+
LogLayer = "LogLayer"
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Interface for mixins to add custom functionality to the LogBuilder prototype.
|
|
951
|
+
*/
|
|
952
|
+
interface LogBuilderMixin {
|
|
953
|
+
/**
|
|
954
|
+
* Specifies that this mixin augments the main LogBuilder class.
|
|
955
|
+
* This type discrimination allows TypeScript to properly type-check mixin usage.
|
|
956
|
+
*/
|
|
957
|
+
augmentationType: LogLayerMixinAugmentType.LogBuilder;
|
|
958
|
+
/**
|
|
959
|
+
* Called at the end of the LogBuilder construct() method.
|
|
960
|
+
* The LogBuilder instance is passed as the first parameter.
|
|
961
|
+
*/
|
|
962
|
+
onConstruct?: (instance: LogBuilder, logger: LogLayer$1) => void;
|
|
963
|
+
/**
|
|
964
|
+
* Function that performs the augmentation of the LogBuilder prototype.
|
|
965
|
+
*
|
|
966
|
+
* @param prototype - The LogBuilder class prototype being augmented
|
|
967
|
+
*/
|
|
968
|
+
augment: (prototype: typeof LogBuilder.prototype) => void;
|
|
969
|
+
/**
|
|
970
|
+
* Function that performs the augmentation of the MockLogBuilder prototype.
|
|
971
|
+
* This is called to ensure the mock class has the same functionality as the real class.
|
|
972
|
+
*
|
|
973
|
+
* @param prototype - The MockLogBuilder class prototype being augmented
|
|
974
|
+
*/
|
|
975
|
+
augmentMock: (prototype: typeof MockLogBuilder.prototype) => void;
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Interface for mixins to add custom functionality to the LogLayer prototype.
|
|
979
|
+
*/
|
|
980
|
+
interface LogLayerMixin {
|
|
981
|
+
/**
|
|
982
|
+
* Specifies that this mixin augments the main LogLayer class.
|
|
983
|
+
* This type discrimination allows TypeScript to properly type-check mixin usage.
|
|
984
|
+
*/
|
|
985
|
+
augmentationType: LogLayerMixinAugmentType.LogLayer;
|
|
986
|
+
/**
|
|
987
|
+
* Called at the end of the LogLayer construct() method.
|
|
988
|
+
* The LogLayer instance is passed as the first parameter.
|
|
989
|
+
*/
|
|
990
|
+
onConstruct?: (instance: LogLayer$1, config: LogLayerConfig) => void;
|
|
991
|
+
/**
|
|
992
|
+
* Function that performs the augmentation of the LogLayer prototype.
|
|
993
|
+
*
|
|
994
|
+
* @param prototype - The LogLayer class prototype being augmented
|
|
995
|
+
*/
|
|
996
|
+
augment: (prototype: typeof LogLayer$1.prototype) => void;
|
|
997
|
+
/**
|
|
998
|
+
* Function that performs the augmentation of the MockLogLayer prototype.
|
|
999
|
+
* This is called to ensure the mock class has the same functionality as the real class.
|
|
1000
|
+
*
|
|
1001
|
+
* @param prototype - The MockLogLayer class prototype being augmented
|
|
1002
|
+
*/
|
|
1003
|
+
augmentMock: (prototype: typeof MockLogLayer$1.prototype) => void;
|
|
1004
|
+
}
|
|
1005
|
+
type LogLayerMixinType = LogBuilderMixin | LogLayerMixin;
|
|
1006
|
+
/**
|
|
1007
|
+
* Interface for registering mixins to LogLayer.
|
|
1008
|
+
*/
|
|
1009
|
+
interface LogLayerMixinRegistration {
|
|
1010
|
+
/**
|
|
1011
|
+
* Array of mixins to add to LogLayer.
|
|
1012
|
+
*/
|
|
1013
|
+
mixinsToAdd: LogLayerMixinType[];
|
|
1014
|
+
/**
|
|
1015
|
+
* Array of plugins to add to LogLayer.
|
|
1016
|
+
*/
|
|
1017
|
+
pluginsToAdd?: LogLayerPlugin[];
|
|
1018
|
+
} //#endregion
|
|
1019
|
+
//#region src/types/index.d.ts
|
|
1020
|
+
type ErrorSerializerType = (err: any) => Record<string, any> | string;
|
|
1021
|
+
/**
|
|
1022
|
+
* Configuration options for LogLayer
|
|
1023
|
+
* @see {@link https://loglayer.dev/configuration.html | LogLayer Configuration Docs}
|
|
1024
|
+
*/
|
|
1025
|
+
interface LogLayerConfig {
|
|
1026
|
+
/**
|
|
1027
|
+
* The prefix to prepend to all log messages
|
|
1028
|
+
*/
|
|
1029
|
+
prefix?: string;
|
|
1030
|
+
/**
|
|
1031
|
+
* Set false to drop all log input and stop sending to the logging
|
|
1032
|
+
* library.
|
|
1033
|
+
*
|
|
1034
|
+
* Can be re-enabled with `enableLogging()`.
|
|
1035
|
+
*
|
|
1036
|
+
* Default is `true`.
|
|
1037
|
+
*/
|
|
1038
|
+
enabled?: boolean;
|
|
1039
|
+
/**
|
|
1040
|
+
* If set to true, will also output messages via console logging before
|
|
1041
|
+
* sending to the logging library.
|
|
1042
|
+
*
|
|
1043
|
+
* Useful for troubleshooting a logging library / transports
|
|
1044
|
+
* to ensure logs are still being created when the underlying
|
|
1045
|
+
* does not print anything.
|
|
1046
|
+
*/
|
|
1047
|
+
consoleDebug?: boolean;
|
|
1048
|
+
/**
|
|
1049
|
+
* The transport(s) that implements a logging library to send logs to.
|
|
1050
|
+
* Can be a single transport or an array of transports.
|
|
1051
|
+
*/
|
|
1052
|
+
transport: LogLayerTransport | Array<LogLayerTransport>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Plugins to use.
|
|
1055
|
+
*/
|
|
1056
|
+
plugins?: Array<LogLayerPlugin>;
|
|
1057
|
+
/**
|
|
1058
|
+
* A function that takes in an incoming Error type and transforms it into an object.
|
|
1059
|
+
* Used in the event that the logging library does not natively support serialization of errors.
|
|
1060
|
+
*/
|
|
1061
|
+
errorSerializer?: ErrorSerializerType;
|
|
1062
|
+
/**
|
|
1063
|
+
* Logging libraries may require a specific field name for errors so it knows
|
|
1064
|
+
* how to parse them.
|
|
1065
|
+
*
|
|
1066
|
+
* Default is 'err'.
|
|
1067
|
+
*/
|
|
1068
|
+
errorFieldName?: string;
|
|
1069
|
+
/**
|
|
1070
|
+
* If true, always copy error.message if available as a log message along
|
|
1071
|
+
* with providing the error data to the logging library.
|
|
1072
|
+
*
|
|
1073
|
+
* Can be overridden individually by setting `copyMsg: false` in the `onlyError()`
|
|
1074
|
+
* call.
|
|
1075
|
+
*
|
|
1076
|
+
* Default is false.
|
|
1077
|
+
*/
|
|
1078
|
+
copyMsgOnOnlyError?: boolean;
|
|
1079
|
+
/**
|
|
1080
|
+
* If set to true, the error will be included as part of metadata instead
|
|
1081
|
+
* of the root of the log data.
|
|
1082
|
+
*
|
|
1083
|
+
* metadataFieldName must be set to true for this to work.
|
|
1084
|
+
*
|
|
1085
|
+
* Default is false.
|
|
1086
|
+
*/
|
|
1087
|
+
errorFieldInMetadata?: boolean;
|
|
1088
|
+
/**
|
|
1089
|
+
* If specified, will set the context object to a specific field
|
|
1090
|
+
* instead of flattening the data alongside the error and message.
|
|
1091
|
+
*
|
|
1092
|
+
* Default is context data will be flattened.
|
|
1093
|
+
*/
|
|
1094
|
+
contextFieldName?: string;
|
|
1095
|
+
/**
|
|
1096
|
+
* If specified, will set the metadata object to a specific field
|
|
1097
|
+
* instead of flattening the data alongside the error and message.
|
|
1098
|
+
*
|
|
1099
|
+
* Default is metadata will be flattened.
|
|
1100
|
+
*/
|
|
1101
|
+
metadataFieldName?: string;
|
|
1102
|
+
/**
|
|
1103
|
+
* If set to true, will not include context data in the log message.
|
|
1104
|
+
*/
|
|
1105
|
+
muteContext?: boolean;
|
|
1106
|
+
/**
|
|
1107
|
+
* If set to true, will not include metadata data in the log message.
|
|
1108
|
+
*/
|
|
1109
|
+
muteMetadata?: boolean;
|
|
1110
|
+
} //#endregion
|
|
1111
|
+
//#region src/LogLayer.d.ts
|
|
1112
|
+
interface FormatLogParams {
|
|
1113
|
+
logLevel: LogLevelType;
|
|
1114
|
+
params?: any[];
|
|
1115
|
+
metadata?: LogLayerMetadata | null;
|
|
1116
|
+
err?: any;
|
|
1117
|
+
context?: LogLayerContext | null;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Wraps around a logging framework to provide convenience methods that allow
|
|
1121
|
+
* developers to programmatically specify their errors and metadata along with
|
|
1122
|
+
* a message in a consistent fashion.
|
|
1123
|
+
*/
|
|
1124
|
+
declare class LogLayer$1 implements ILogLayer<LogLayer$1> {
|
|
1125
|
+
private pluginManager;
|
|
1126
|
+
private idToTransport;
|
|
1127
|
+
private hasMultipleTransports;
|
|
1128
|
+
private singleTransport;
|
|
1129
|
+
private contextManager;
|
|
1130
|
+
private logLevelManager;
|
|
1131
|
+
/**
|
|
1132
|
+
* The configuration object used to initialize the logger.
|
|
1133
|
+
* This is for internal use only and should not be modified directly.
|
|
1134
|
+
*/
|
|
1135
|
+
_config: LogLayerConfig;
|
|
1136
|
+
constructor(config: LogLayerConfig);
|
|
1137
|
+
/**
|
|
1138
|
+
* Sets the context manager to use for managing context data.
|
|
1139
|
+
*/
|
|
1140
|
+
withContextManager(contextManager: IContextManager): LogLayer$1;
|
|
1141
|
+
/**
|
|
1142
|
+
* Returns the context manager instance being used.
|
|
1143
|
+
*/
|
|
1144
|
+
getContextManager<M extends IContextManager = IContextManager>(): M;
|
|
1145
|
+
/**
|
|
1146
|
+
* Sets the log level manager to use for managing log levels.
|
|
1147
|
+
*/
|
|
1148
|
+
withLogLevelManager(logLevelManager: ILogLevelManager): LogLayer$1;
|
|
1149
|
+
/**
|
|
1150
|
+
* Returns the log level manager instance being used.
|
|
1151
|
+
*/
|
|
1152
|
+
getLogLevelManager<M extends ILogLevelManager = ILogLevelManager>(): M;
|
|
1153
|
+
/**
|
|
1154
|
+
* Returns the configuration object used to initialize the logger.
|
|
1155
|
+
*/
|
|
1156
|
+
getConfig(): LogLayerConfig;
|
|
1157
|
+
private _initializeTransports;
|
|
1158
|
+
/**
|
|
1159
|
+
* Calls child() and sets the prefix to be included with every log message.
|
|
1160
|
+
*
|
|
1161
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#message-prefixing | Message Prefixing Docs}
|
|
1162
|
+
*/
|
|
1163
|
+
withPrefix(prefix: string): LogLayer$1;
|
|
1164
|
+
/**
|
|
1165
|
+
* Appends context data which will be included with
|
|
1166
|
+
* every log entry.
|
|
1167
|
+
*
|
|
1168
|
+
* Passing in an empty value / object will *not* clear the context.
|
|
1169
|
+
*
|
|
1170
|
+
* To clear the context, use {@link https://loglayer.dev/logging-api/context.html#clearing-context | clearContext()}.
|
|
1171
|
+
*
|
|
1172
|
+
* @see {@link https://loglayer.dev/logging-api/context.html | Context Docs}
|
|
1173
|
+
*/
|
|
1174
|
+
withContext(context?: LogLayerContext): LogLayer$1;
|
|
1175
|
+
/**
|
|
1176
|
+
* Clears the context data. If keys are provided, only those keys will be removed.
|
|
1177
|
+
* If no keys are provided, all context data will be cleared.
|
|
1178
|
+
*/
|
|
1179
|
+
clearContext(keys?: string | string[]): this;
|
|
1180
|
+
getContext(): LogLayerContext;
|
|
1181
|
+
/**
|
|
1182
|
+
* Add additional plugins.
|
|
1183
|
+
*
|
|
1184
|
+
* @see {@link https://loglayer.dev/plugins/ | Plugins Docs}
|
|
1185
|
+
*/
|
|
1186
|
+
addPlugins(plugins: Array<LogLayerPlugin>): void;
|
|
1187
|
+
/**
|
|
1188
|
+
* Enables a plugin by id.
|
|
1189
|
+
*
|
|
1190
|
+
* @see {@link https://loglayer.dev/plugins/ | Plugins Docs}
|
|
1191
|
+
*/
|
|
1192
|
+
enablePlugin(id: string): void;
|
|
1193
|
+
/**
|
|
1194
|
+
* Disables a plugin by id.
|
|
1195
|
+
*
|
|
1196
|
+
* @see {@link https://loglayer.dev/plugins/ | Plugins Docs}
|
|
1197
|
+
*/
|
|
1198
|
+
disablePlugin(id: string): void;
|
|
1199
|
+
/**
|
|
1200
|
+
* Removes a plugin by id.
|
|
1201
|
+
*
|
|
1202
|
+
* @see {@link https://loglayer.dev/plugins/ | Plugins Docs}
|
|
1203
|
+
*/
|
|
1204
|
+
removePlugin(id: string): void;
|
|
1205
|
+
/**
|
|
1206
|
+
* Specifies metadata to include with the log message
|
|
1207
|
+
*
|
|
1208
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html | Metadata Docs}
|
|
1209
|
+
*/
|
|
1210
|
+
withMetadata(metadata?: LogLayerMetadata): LogBuilder;
|
|
1211
|
+
/**
|
|
1212
|
+
* Specifies an Error to include with the log message
|
|
1213
|
+
*
|
|
1214
|
+
* @see {@link https://loglayer.dev/logging-api/error-handling.html | Error Handling Docs}
|
|
1215
|
+
*/
|
|
1216
|
+
withError(error: any): LogBuilder;
|
|
1217
|
+
/**
|
|
1218
|
+
* Creates a new instance of LogLayer but with the initialization
|
|
1219
|
+
* configuration and context copied over.
|
|
1220
|
+
*
|
|
1221
|
+
* @see {@link https://loglayer.dev/logging-api/child-loggers.html | Child Logging Docs}
|
|
1222
|
+
*/
|
|
1223
|
+
child(): LogLayer$1;
|
|
1224
|
+
/**
|
|
1225
|
+
* Replaces all existing transports with new ones.
|
|
1226
|
+
*
|
|
1227
|
+
* Transport changes only affect the current logger instance. Child loggers
|
|
1228
|
+
* created before the change will retain their original transports, and
|
|
1229
|
+
* parent loggers are not affected when a child modifies its transports.
|
|
1230
|
+
*
|
|
1231
|
+
* @see {@link https://loglayer.dev/logging-api/transport-management.html | Transport Management Docs}
|
|
1232
|
+
*/
|
|
1233
|
+
withFreshTransports(transports: LogLayerTransport | Array<LogLayerTransport>): LogLayer$1;
|
|
1234
|
+
/**
|
|
1235
|
+
* Adds one or more transports to the existing transports.
|
|
1236
|
+
* If a transport with the same ID already exists, it will be replaced.
|
|
1237
|
+
*
|
|
1238
|
+
* Transport changes only affect the current logger instance. Child loggers
|
|
1239
|
+
* created before the change will retain their original transports, and
|
|
1240
|
+
* parent loggers are not affected when a child modifies its transports.
|
|
1241
|
+
*
|
|
1242
|
+
* @see {@link https://loglayer.dev/logging-api/transport-management.html | Transport Management Docs}
|
|
1243
|
+
*/
|
|
1244
|
+
addTransport(transports: LogLayerTransport | Array<LogLayerTransport>): LogLayer$1;
|
|
1245
|
+
/**
|
|
1246
|
+
* Removes a transport by its ID.
|
|
1247
|
+
*
|
|
1248
|
+
* Transport changes only affect the current logger instance. Child loggers
|
|
1249
|
+
* created before the change will retain their original transports, and
|
|
1250
|
+
* parent loggers are not affected when a child modifies its transports.
|
|
1251
|
+
*
|
|
1252
|
+
* @returns true if the transport was found and removed, false otherwise.
|
|
1253
|
+
*
|
|
1254
|
+
* @see {@link https://loglayer.dev/logging-api/transport-management.html | Transport Management Docs}
|
|
1255
|
+
*/
|
|
1256
|
+
removeTransport(id: string): boolean;
|
|
1257
|
+
/**
|
|
1258
|
+
* Replaces all existing plugins with new ones.
|
|
1259
|
+
*
|
|
1260
|
+
* When used with child loggers, it only affects the current logger instance
|
|
1261
|
+
* and does not modify the parent's plugins.
|
|
1262
|
+
*
|
|
1263
|
+
* @see {@link https://loglayer.dev/plugins/ | Plugins Docs}
|
|
1264
|
+
*/
|
|
1265
|
+
withFreshPlugins(plugins: Array<LogLayerPlugin>): LogLayer$1;
|
|
1266
|
+
protected withPluginManager(pluginManager: PluginManager): this;
|
|
1267
|
+
/**
|
|
1268
|
+
* Logs only the error object without a log message
|
|
1269
|
+
*
|
|
1270
|
+
* @see {@link https://loglayer.dev/logging-api/error-handling.html | Error Handling Docs}
|
|
1271
|
+
*/
|
|
1272
|
+
errorOnly(error: any, opts?: ErrorOnlyOpts): void;
|
|
1273
|
+
/**
|
|
1274
|
+
* Logs only metadata without a log message
|
|
1275
|
+
*
|
|
1276
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html | Metadata Docs}
|
|
1277
|
+
*/
|
|
1278
|
+
metadataOnly(metadata?: LogLayerMetadata, logLevel?: LogLevelType): void;
|
|
1279
|
+
/**
|
|
1280
|
+
* Sends a log message to the logging library under an info log level.
|
|
1281
|
+
*
|
|
1282
|
+
* The logging library may or may not support multiple message parameters and only
|
|
1283
|
+
* the first parameter would be used.
|
|
1284
|
+
*
|
|
1285
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html | Basic Logging Docs}
|
|
1286
|
+
*/
|
|
1287
|
+
info(...messages: MessageDataType[]): void;
|
|
1288
|
+
/**
|
|
1289
|
+
* Sends a log message to the logging library under the warn log level
|
|
1290
|
+
*
|
|
1291
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html | Basic Logging Docs}
|
|
1292
|
+
*/
|
|
1293
|
+
warn(...messages: MessageDataType[]): void;
|
|
1294
|
+
/**
|
|
1295
|
+
* Sends a log message to the logging library under the error log level
|
|
1296
|
+
*
|
|
1297
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html | Basic Logging Docs}
|
|
1298
|
+
*/
|
|
1299
|
+
error(...messages: MessageDataType[]): void;
|
|
1300
|
+
/**
|
|
1301
|
+
* Sends a log message to the logging library under the debug log level
|
|
1302
|
+
*
|
|
1303
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html | Basic Logging Docs}
|
|
1304
|
+
*/
|
|
1305
|
+
debug(...messages: MessageDataType[]): void;
|
|
1306
|
+
/**
|
|
1307
|
+
* Sends a log message to the logging library under the trace log level
|
|
1308
|
+
*
|
|
1309
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html | Basic Logging Docs}
|
|
1310
|
+
*/
|
|
1311
|
+
trace(...messages: MessageDataType[]): void;
|
|
1312
|
+
/**
|
|
1313
|
+
* Sends a log message to the logging library under the fatal log level
|
|
1314
|
+
*
|
|
1315
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html | Basic Logging Docs}
|
|
1316
|
+
*/
|
|
1317
|
+
fatal(...messages: MessageDataType[]): void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Logs a raw log entry with complete control over all log parameters.
|
|
1320
|
+
*
|
|
1321
|
+
* This method allows you to bypass the normal LogLayer API and directly specify
|
|
1322
|
+
* all aspects of a log entry including log level, messages, metadata, and error.
|
|
1323
|
+
* It's useful for scenarios where you need to log structured data that doesn't
|
|
1324
|
+
* fit the standard LogLayer patterns, or when integrating with external logging
|
|
1325
|
+
* systems that provide pre-formatted log entries.
|
|
1326
|
+
*
|
|
1327
|
+
* The raw entry will still go through all LogLayer processing.
|
|
1328
|
+
*
|
|
1329
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html | Basic Logging Docs}
|
|
1330
|
+
*/
|
|
1331
|
+
raw(logEntry: RawLogEntry): void;
|
|
1332
|
+
/**
|
|
1333
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
1334
|
+
*
|
|
1335
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
1336
|
+
*/
|
|
1337
|
+
disableLogging(): this;
|
|
1338
|
+
/**
|
|
1339
|
+
* Enable sending logs to the logging library.
|
|
1340
|
+
*
|
|
1341
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
1342
|
+
*/
|
|
1343
|
+
enableLogging(): this;
|
|
1344
|
+
/**
|
|
1345
|
+
* Disables inclusion of context data in the print
|
|
1346
|
+
*
|
|
1347
|
+
* @see {@link https://loglayer.dev/logging-api/context.html#managing-context | Managing Context Docs}
|
|
1348
|
+
*/
|
|
1349
|
+
muteContext(): this;
|
|
1350
|
+
/**
|
|
1351
|
+
* Enables inclusion of context data in the print
|
|
1352
|
+
*
|
|
1353
|
+
* @see {@link https://loglayer.dev/logging-api/context.html#managing-context | Managing Context Docs}
|
|
1354
|
+
*/
|
|
1355
|
+
unMuteContext(): this;
|
|
1356
|
+
/**
|
|
1357
|
+
* Disables inclusion of metadata in the print
|
|
1358
|
+
*
|
|
1359
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html#controlling-metadata-output | Controlling Metadata Output Docs}
|
|
1360
|
+
*/
|
|
1361
|
+
muteMetadata(): this;
|
|
1362
|
+
/**
|
|
1363
|
+
* Enables inclusion of metadata in the print
|
|
1364
|
+
*
|
|
1365
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html#controlling-metadata-output | Controlling Metadata Output Docs}
|
|
1366
|
+
*/
|
|
1367
|
+
unMuteMetadata(): this;
|
|
1368
|
+
/**
|
|
1369
|
+
* Enables a specific log level
|
|
1370
|
+
*
|
|
1371
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
1372
|
+
*/
|
|
1373
|
+
enableIndividualLevel(logLevel: LogLevelType): this;
|
|
1374
|
+
/**
|
|
1375
|
+
* Disables a specific log level
|
|
1376
|
+
*
|
|
1377
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
1378
|
+
*/
|
|
1379
|
+
disableIndividualLevel(logLevel: LogLevelType): this;
|
|
1380
|
+
/**
|
|
1381
|
+
* Sets the minimum log level to be used by the logger. Only messages with
|
|
1382
|
+
* this level or higher severity will be logged.
|
|
1383
|
+
*
|
|
1384
|
+
* For example, if you setLevel(LogLevel.warn), this will:
|
|
1385
|
+
* Enable:
|
|
1386
|
+
* - warn
|
|
1387
|
+
* - error
|
|
1388
|
+
* - fatal
|
|
1389
|
+
* Disable:
|
|
1390
|
+
* - info
|
|
1391
|
+
* - debug
|
|
1392
|
+
* - trace
|
|
1393
|
+
*
|
|
1394
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#enabling-disabling-logging | Enabling/Disabling Logging Docs}
|
|
1395
|
+
*/
|
|
1396
|
+
setLevel(logLevel: LogLevelType): this;
|
|
1397
|
+
/**
|
|
1398
|
+
* Checks if a specific log level is enabled
|
|
1399
|
+
*
|
|
1400
|
+
* @see {@link https://loglayer.dev/logging-api/basic-logging.html#checking-if-a-log-level-is-enabled | Checking if a Log Level is Enabled Docs}
|
|
1401
|
+
*/
|
|
1402
|
+
isLevelEnabled(logLevel: LogLevelType): boolean;
|
|
1403
|
+
private formatContext;
|
|
1404
|
+
private formatMetadata;
|
|
1405
|
+
/**
|
|
1406
|
+
* Returns a logger instance for a specific transport
|
|
1407
|
+
*
|
|
1408
|
+
* @see {@link https://loglayer.dev/logging-api/transport-management.html | Transport Management Docs}
|
|
1409
|
+
*/
|
|
1410
|
+
getLoggerInstance<Logger>(id: string): Logger | undefined;
|
|
1411
|
+
_formatMessage(messages?: MessageDataType[]): void;
|
|
1412
|
+
_formatLog({
|
|
1413
|
+
logLevel,
|
|
1414
|
+
params,
|
|
1415
|
+
metadata,
|
|
1416
|
+
err,
|
|
1417
|
+
context
|
|
1418
|
+
}: FormatLogParams): void;
|
|
1419
|
+
} //#endregion
|
|
1420
|
+
//#region src/LogBuilder.d.ts
|
|
1421
|
+
/**
|
|
1422
|
+
* A class that contains methods to specify log metadata and an error and assembles
|
|
1423
|
+
* it to form a data object that can be passed into the transport.
|
|
1424
|
+
*/
|
|
1425
|
+
declare class LogBuilder implements ILogBuilder<LogBuilder> {
|
|
1426
|
+
private err;
|
|
1427
|
+
private metadata;
|
|
1428
|
+
private structuredLogger;
|
|
1429
|
+
private hasMetadata;
|
|
1430
|
+
private pluginManager;
|
|
1431
|
+
constructor(structuredLogger: LogLayer$1);
|
|
1432
|
+
/**
|
|
1433
|
+
* Specifies metadata to include with the log message
|
|
1434
|
+
*
|
|
1435
|
+
* @see {@link https://loglayer.dev/logging-api/metadata.html | Metadata Docs}
|
|
1436
|
+
*/
|
|
1437
|
+
withMetadata(metadata?: LogLayerMetadata): this;
|
|
1438
|
+
/**
|
|
1439
|
+
* Specifies an Error to include with the log message
|
|
1440
|
+
*
|
|
1441
|
+
* @see {@link https://loglayer.dev/logging-api/error-handling.html | Error Handling Docs}
|
|
1442
|
+
*/
|
|
1443
|
+
withError(error: any): this;
|
|
1444
|
+
/**
|
|
1445
|
+
* Sends a log message to the logging library under an info log level.
|
|
1446
|
+
*/
|
|
1447
|
+
info(...messages: MessageDataType[]): void;
|
|
1448
|
+
/**
|
|
1449
|
+
* Sends a log message to the logging library under the warn log level
|
|
1450
|
+
*/
|
|
1451
|
+
warn(...messages: MessageDataType[]): void;
|
|
1452
|
+
/**
|
|
1453
|
+
* Sends a log message to the logging library under the error log level
|
|
1454
|
+
*/
|
|
1455
|
+
error(...messages: MessageDataType[]): void;
|
|
1456
|
+
/**
|
|
1457
|
+
* Sends a log message to the logging library under the debug log level
|
|
1458
|
+
*
|
|
1459
|
+
* The logging library may or may not support multiple message parameters and only
|
|
1460
|
+
* the first parameter would be used.
|
|
1461
|
+
*/
|
|
1462
|
+
debug(...messages: MessageDataType[]): void;
|
|
1463
|
+
/**
|
|
1464
|
+
* Sends a log message to the logging library under the trace log level
|
|
1465
|
+
*
|
|
1466
|
+
* The logging library may or may not support multiple message parameters and only
|
|
1467
|
+
* the first parameter would be used.
|
|
1468
|
+
*/
|
|
1469
|
+
trace(...messages: MessageDataType[]): void;
|
|
1470
|
+
/**
|
|
1471
|
+
* Sends a log message to the logging library under the fatal log level
|
|
1472
|
+
*
|
|
1473
|
+
* The logging library may or may not support multiple message parameters and only
|
|
1474
|
+
* the first parameter would be used.
|
|
1475
|
+
*/
|
|
1476
|
+
fatal(...messages: MessageDataType[]): void;
|
|
1477
|
+
/**
|
|
1478
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
1479
|
+
*/
|
|
1480
|
+
disableLogging(): this;
|
|
1481
|
+
/**
|
|
1482
|
+
* Enable sending logs to the logging library.
|
|
1483
|
+
*/
|
|
1484
|
+
enableLogging(): this;
|
|
1485
|
+
private formatLog;
|
|
1486
|
+
} //#endregion
|
|
1487
|
+
//#region src/mixins.d.ts
|
|
1488
|
+
/**
|
|
1489
|
+
* Adds one or more mixins to LogLayer.
|
|
1490
|
+
* @param mixin - The mixin(s) to register. Can be a single mixin registration or an array of mixin registrations.
|
|
1491
|
+
*/
|
|
1492
|
+
//#endregion
|
|
1493
|
+
//#region src/types.d.ts
|
|
1494
|
+
/**
|
|
1495
|
+
* Options for creating a BufferedMetricsLogger instance.
|
|
1496
|
+
* Re-exported from the datadog-metrics library for convenience.
|
|
1497
|
+
*/
|
|
1498
|
+
type DatadogMetricsOptions = BufferedMetricsLoggerOptions$1;
|
|
1499
|
+
/**
|
|
1500
|
+
* Histogram aggregation and percentile options
|
|
1501
|
+
*/
|
|
1502
|
+
interface HistogramOptions {
|
|
1503
|
+
/** Aggregation types: 'max', 'min', 'sum', 'avg', 'count', 'median' */
|
|
1504
|
+
aggregates?: string[];
|
|
1505
|
+
/** Percentile values between 0 and 1, e.g. [0.95, 0.99] */
|
|
1506
|
+
percentiles?: number[];
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Builder interface for chaining metric configurations
|
|
1510
|
+
*/
|
|
1511
|
+
interface IMetricsBuilder {
|
|
1512
|
+
/**
|
|
1513
|
+
* Add tags to the metric
|
|
1514
|
+
*/
|
|
1515
|
+
withTags(tags: string[]): IMetricsBuilder;
|
|
1516
|
+
/**
|
|
1517
|
+
* Set the timestamp for the metric in milliseconds since epoch
|
|
1518
|
+
*/
|
|
1519
|
+
withTimestamp(timestamp: number): IMetricsBuilder;
|
|
1520
|
+
/**
|
|
1521
|
+
* Send the metric with the configured options
|
|
1522
|
+
*/
|
|
1523
|
+
send(): void;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Builder interface for increment method with withValue support
|
|
1527
|
+
*/
|
|
1528
|
+
interface IIncrementBuilder extends IMetricsBuilder {
|
|
1529
|
+
/**
|
|
1530
|
+
* Set the increment value (defaults to 1)
|
|
1531
|
+
*/
|
|
1532
|
+
withValue(value: number): IIncrementBuilder;
|
|
1533
|
+
withTags(tags: string[]): IIncrementBuilder;
|
|
1534
|
+
withTimestamp(timestamp: number): IIncrementBuilder;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Builder interface for histogram method with histogram options support
|
|
1538
|
+
*/
|
|
1539
|
+
interface IHistogramBuilder extends IMetricsBuilder {
|
|
1540
|
+
/**
|
|
1541
|
+
* Set histogram-specific options (aggregates and percentiles)
|
|
1542
|
+
*/
|
|
1543
|
+
withHistogramOptions(options: HistogramOptions): IHistogramBuilder;
|
|
1544
|
+
withTags(tags: string[]): IHistogramBuilder;
|
|
1545
|
+
withTimestamp(timestamp: number): IHistogramBuilder;
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Metrics API interface containing all datadog-metrics methods
|
|
1549
|
+
*/
|
|
1550
|
+
interface IMetricsAPI {
|
|
1551
|
+
/**
|
|
1552
|
+
* Increment a counter metric
|
|
1553
|
+
*/
|
|
1554
|
+
increment(key: string): IIncrementBuilder;
|
|
1555
|
+
/**
|
|
1556
|
+
* Set a gauge metric to a specific value
|
|
1557
|
+
*/
|
|
1558
|
+
gauge(key: string, value: number): IMetricsBuilder;
|
|
1559
|
+
/**
|
|
1560
|
+
* Record a histogram value
|
|
1561
|
+
*/
|
|
1562
|
+
histogram(key: string, value: number): IHistogramBuilder;
|
|
1563
|
+
/**
|
|
1564
|
+
* Record a distribution value (server-side calculated)
|
|
1565
|
+
*/
|
|
1566
|
+
distribution(key: string, value: number): IMetricsBuilder;
|
|
1567
|
+
/**
|
|
1568
|
+
* Flush all buffered metrics to Datadog immediately
|
|
1569
|
+
*/
|
|
1570
|
+
flush(): Promise<void>;
|
|
1571
|
+
/**
|
|
1572
|
+
* Start auto-flushing metrics at the configured interval
|
|
1573
|
+
*/
|
|
1574
|
+
start(): void;
|
|
1575
|
+
/**
|
|
1576
|
+
* Stop auto-flushing and optionally flush remaining metrics
|
|
1577
|
+
*/
|
|
1578
|
+
stop(options?: {
|
|
1579
|
+
flush?: boolean;
|
|
1580
|
+
}): Promise<void>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Get the underlying BufferedMetricsLogger instance
|
|
1583
|
+
*/
|
|
1584
|
+
getClient(): BufferedMetricsLogger$1;
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Generic mixin interface for Datadog HTTP metrics methods.
|
|
1588
|
+
* T is the instance type (LogLayer or MockLogLayer).
|
|
1589
|
+
*/
|
|
1590
|
+
interface IDatadogMetricsMixin<_T> {
|
|
1591
|
+
/**
|
|
1592
|
+
* Access to Datadog HTTP metrics API
|
|
1593
|
+
*/
|
|
1594
|
+
ddStats: IMetricsAPI;
|
|
1595
|
+
}
|
|
1596
|
+
declare module "loglayer" {
|
|
1597
|
+
interface LogLayer extends IDatadogMetricsMixin<LogLayer> {}
|
|
1598
|
+
interface MockLogLayer extends IDatadogMetricsMixin<MockLogLayer> {}
|
|
1599
|
+
interface ILogLayer<This> extends IDatadogMetricsMixin<This> {}
|
|
1600
|
+
}
|
|
1601
|
+
//#endregion
|
|
1602
|
+
//#region src/MetricsAPI.d.ts
|
|
1603
|
+
/**
|
|
1604
|
+
* Metrics API implementation that wraps datadog-metrics BufferedMetricsLogger.
|
|
1605
|
+
* Provides a fluent interface for sending metrics to Datadog via HTTP.
|
|
1606
|
+
*/
|
|
1607
|
+
declare class MetricsAPI implements IMetricsAPI {
|
|
1608
|
+
private readonly client;
|
|
1609
|
+
/**
|
|
1610
|
+
* Creates a new MetricsAPI instance.
|
|
1611
|
+
*
|
|
1612
|
+
* @param client - The datadog-metrics BufferedMetricsLogger instance
|
|
1613
|
+
*/
|
|
1614
|
+
constructor(client: BufferedMetricsLogger$1);
|
|
1615
|
+
/**
|
|
1616
|
+
* Increment a counter metric.
|
|
1617
|
+
* Returns a builder that supports chaining with withValue(), withTags(), and withTimestamp().
|
|
1618
|
+
*
|
|
1619
|
+
* @param key - The metric key to increment
|
|
1620
|
+
* @returns A builder instance for chaining additional options
|
|
1621
|
+
*/
|
|
1622
|
+
increment(key: string): IIncrementBuilder;
|
|
1623
|
+
/**
|
|
1624
|
+
* Set a gauge metric to a specific value.
|
|
1625
|
+
* Returns a builder that supports chaining with withTags() and withTimestamp().
|
|
1626
|
+
*
|
|
1627
|
+
* @param key - The metric key to set
|
|
1628
|
+
* @param value - The value to set the gauge to
|
|
1629
|
+
* @returns A builder instance for chaining additional options
|
|
1630
|
+
*/
|
|
1631
|
+
gauge(key: string, value: number): IMetricsBuilder;
|
|
1632
|
+
/**
|
|
1633
|
+
* Record a histogram value.
|
|
1634
|
+
* Returns a builder that supports chaining with withTags(), withTimestamp(), and withHistogramOptions().
|
|
1635
|
+
*
|
|
1636
|
+
* @param key - The metric key to record
|
|
1637
|
+
* @param value - The histogram value to record
|
|
1638
|
+
* @returns A builder instance for chaining additional options
|
|
1639
|
+
*/
|
|
1640
|
+
histogram(key: string, value: number): IHistogramBuilder;
|
|
1641
|
+
/**
|
|
1642
|
+
* Record a distribution value (server-side calculated).
|
|
1643
|
+
* Returns a builder that supports chaining with withTags() and withTimestamp().
|
|
1644
|
+
*
|
|
1645
|
+
* @param key - The metric key to record
|
|
1646
|
+
* @param value - The distribution value to record
|
|
1647
|
+
* @returns A builder instance for chaining additional options
|
|
1648
|
+
*/
|
|
1649
|
+
distribution(key: string, value: number): IMetricsBuilder;
|
|
1650
|
+
/**
|
|
1651
|
+
* Flush all buffered metrics to Datadog immediately.
|
|
1652
|
+
*
|
|
1653
|
+
* @returns A promise that resolves when the flush completes
|
|
1654
|
+
*/
|
|
1655
|
+
flush(): Promise<void>;
|
|
1656
|
+
/**
|
|
1657
|
+
* Start auto-flushing metrics at the configured interval.
|
|
1658
|
+
*/
|
|
1659
|
+
start(): void;
|
|
1660
|
+
/**
|
|
1661
|
+
* Stop auto-flushing and optionally flush remaining metrics.
|
|
1662
|
+
*
|
|
1663
|
+
* @param options - Options for stopping. `flush` defaults to true.
|
|
1664
|
+
* @returns A promise that resolves when stopping completes
|
|
1665
|
+
*/
|
|
1666
|
+
stop(options?: {
|
|
1667
|
+
flush?: boolean;
|
|
1668
|
+
}): Promise<void>;
|
|
1669
|
+
/**
|
|
1670
|
+
* Get the underlying BufferedMetricsLogger instance.
|
|
1671
|
+
*
|
|
1672
|
+
* @returns The BufferedMetricsLogger instance
|
|
1673
|
+
*/
|
|
1674
|
+
getClient(): BufferedMetricsLogger$1;
|
|
1675
|
+
}
|
|
1676
|
+
//#endregion
|
|
1677
|
+
//#region src/MockMetricsAPI.d.ts
|
|
1678
|
+
/**
|
|
1679
|
+
* No-op implementation of IMetricsAPI.
|
|
1680
|
+
* All methods return mock builder instances that do nothing when send() is called.
|
|
1681
|
+
* This is used when datadogMetricsMixin(null) is called, allowing the metrics API
|
|
1682
|
+
* to be used without actually sending any metrics.
|
|
1683
|
+
*/
|
|
1684
|
+
declare class MockMetricsAPI implements IMetricsAPI {
|
|
1685
|
+
increment(key: string): IIncrementBuilder;
|
|
1686
|
+
gauge(key: string, value: number): IMetricsBuilder;
|
|
1687
|
+
histogram(key: string, value: number): IHistogramBuilder;
|
|
1688
|
+
distribution(key: string, value: number): IMetricsBuilder;
|
|
1689
|
+
flush(): Promise<void>;
|
|
1690
|
+
start(): void;
|
|
1691
|
+
stop(_options?: {
|
|
1692
|
+
flush?: boolean;
|
|
1693
|
+
}): Promise<void>;
|
|
1694
|
+
getClient(): BufferedMetricsLogger$1;
|
|
1695
|
+
}
|
|
1696
|
+
//#endregion
|
|
1697
|
+
//#region src/index.d.ts
|
|
1698
|
+
declare const BufferedMetricsLogger: typeof metrics.BufferedMetricsLogger;
|
|
1699
|
+
/**
|
|
1700
|
+
* A reporter that discards all metrics. Useful for testing or temporarily
|
|
1701
|
+
* disabling metric submission without using the `enabled` flag.
|
|
1702
|
+
* Re-exported from the `datadog-metrics` library.
|
|
1703
|
+
*/
|
|
1704
|
+
declare const NullReporter: typeof metrics.reporters.NullReporter;
|
|
1705
|
+
/**
|
|
1706
|
+
* The default reporter that sends metrics to Datadog's HTTP API with automatic retries.
|
|
1707
|
+
* Re-exported from the `datadog-metrics` library.
|
|
1708
|
+
*/
|
|
1709
|
+
declare const DatadogReporter: typeof metrics.reporters.DatadogReporter;
|
|
1710
|
+
/**
|
|
1711
|
+
* Register the datadog-metrics mixin with LogLayer.
|
|
1712
|
+
* This adds a `ddStats` property to LogLayer instances,
|
|
1713
|
+
* providing a fluent API for sending metrics to Datadog via HTTP.
|
|
1714
|
+
*
|
|
1715
|
+
* @param options - The BufferedMetricsLogger configuration options, or null for no-op mode.
|
|
1716
|
+
* Set `enabled: false` to use no-op mode while still passing options.
|
|
1717
|
+
* @returns A LogLayer mixin registration object
|
|
1718
|
+
*
|
|
1719
|
+
* @example
|
|
1720
|
+
* ```typescript
|
|
1721
|
+
* import { useLogLayerMixin } from 'loglayer';
|
|
1722
|
+
* import { datadogMetricsMixin } from '@loglayer/mixin-datadog-http-metrics';
|
|
1723
|
+
*
|
|
1724
|
+
* useLogLayerMixin(datadogMetricsMixin({
|
|
1725
|
+
* apiKey: 'your-api-key',
|
|
1726
|
+
* prefix: 'myapp.',
|
|
1727
|
+
* enabled: process.env.NODE_ENV === 'production',
|
|
1728
|
+
* }));
|
|
1729
|
+
* ```
|
|
1730
|
+
*/
|
|
1731
|
+
declare function datadogMetricsMixin(options: (DatadogMetricsOptions & {
|
|
1732
|
+
enabled?: boolean;
|
|
1733
|
+
}) | null): LogLayerMixinRegistration;
|
|
1734
|
+
//#endregion
|
|
1735
|
+
export { BufferedMetricsLogger, type BufferedMetricsLoggerOptions, type DatadogMetricsOptions, DatadogReporter, type HistogramOptions, type IDatadogMetricsMixin, type IHistogramBuilder, type IIncrementBuilder, type IMetricsAPI, type IMetricsBuilder, MetricsAPI, MockMetricsAPI, NullReporter, datadogMetricsMixin };
|