react-hook-eslint 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/pino.d.ts ADDED
@@ -0,0 +1,889 @@
1
+ // Project: https://github.com/pinojs/pino.git, http://getpino.io
2
+ // Definitions by: Peter Snider <https://github.com/psnider>
3
+ // BendingBender <https://github.com/BendingBender>
4
+ // Christian Rackerseder <https://github.com/screendriver>
5
+ // GP <https://github.com/paambaati>
6
+ // Alex Ferrando <https://github.com/alferpal>
7
+ // Oleksandr Sidko <https://github.com/mortiy>
8
+ // Harris Lummis <https://github.com/lummish>
9
+ // Raoul Jaeckel <https://github.com/raoulus>
10
+ // Cory Donkin <https://github.com/Cooryd>
11
+ // Adam Vigneaux <https://github.com/AdamVig>
12
+ // Austin Beer <https://github.com/austin-beer>
13
+ // Michel Nemnom <https://github.com/Pegase745>
14
+ // Igor Savin <https://github.com/kibertoad>
15
+ // James Bromwell <https://github.com/thw0rted>
16
+ // TypeScript Version: 4.4
17
+
18
+ import type { EventEmitter } from "events";
19
+ import * as pinoStdSerializers from "pino-std-serializers";
20
+ import type { SonicBoom, SonicBoomOpts } from "sonic-boom";
21
+ import type { WorkerOptions } from "worker_threads";
22
+
23
+
24
+
25
+ //// Non-exported types and interfaces
26
+
27
+ // ToDo https://github.com/pinojs/thread-stream/issues/24
28
+ type ThreadStream = any
29
+
30
+ type TimeFn = () => string;
31
+ type MixinFn<CustomLevels extends string = never> = (mergeObject: object, level: number, logger:pino.Logger<CustomLevels>) => object;
32
+ type MixinMergeStrategyFn = (mergeObject: object, mixinObject: object) => object;
33
+
34
+ type CustomLevelLogger<CustomLevels extends string, UseOnlyCustomLevels extends boolean = boolean> = {
35
+ /**
36
+ * Define additional logging levels.
37
+ */
38
+ customLevels: { [level in CustomLevels]: number };
39
+ /**
40
+ * Use only defined `customLevels` and omit Pino's levels.
41
+ */
42
+ useOnlyCustomLevels: UseOnlyCustomLevels;
43
+ } & {
44
+ // This will override default log methods
45
+ [K in Exclude<pino.Level, CustomLevels>]: UseOnlyCustomLevels extends true ? never : pino.LogFn;
46
+ } & {
47
+ [level in CustomLevels]: pino.LogFn;
48
+ };
49
+
50
+ /**
51
+ * A synchronous callback that will run on each creation of a new child.
52
+ * @param child: The newly created child logger instance.
53
+ */
54
+ type OnChildCallback<CustomLevels extends string = never> = (child: pino.Logger<CustomLevels>) => void
55
+
56
+ export interface redactOptions {
57
+ paths: string[];
58
+ censor?: string | ((value: any, path: string[]) => any);
59
+ remove?: boolean;
60
+ }
61
+
62
+ export interface LoggerExtras<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> extends EventEmitter {
63
+ /**
64
+ * Exposes the Pino package version. Also available on the exported pino function.
65
+ */
66
+ readonly version: string;
67
+
68
+ levels: pino.LevelMapping;
69
+
70
+ /**
71
+ * Outputs the level as a string instead of integer.
72
+ */
73
+ useLevelLabels: boolean;
74
+ /**
75
+ * Returns the integer value for the logger instance's logging level.
76
+ */
77
+ levelVal: number;
78
+
79
+ /**
80
+ * Creates a child logger, setting all key-value pairs in `bindings` as properties in the log lines. All serializers will be applied to the given pair.
81
+ * Child loggers use the same output stream as the parent and inherit the current log level of the parent at the time they are spawned.
82
+ * From v2.x.x the log level of a child is mutable (whereas in v1.x.x it was immutable), and can be set independently of the parent.
83
+ * If a `level` property is present in the object passed to `child` it will override the child logger level.
84
+ *
85
+ * @param bindings: an object of key-value pairs to include in log lines as properties.
86
+ * @param options: an options object that will override child logger inherited options.
87
+ * @returns a child logger instance.
88
+ */
89
+ child<ChildCustomLevels extends string = never>(bindings: pino.Bindings, options?: ChildLoggerOptions<ChildCustomLevels>): pino.Logger<CustomLevels | ChildCustomLevels>;
90
+
91
+ /**
92
+ * This can be used to modify the callback function on creation of a new child.
93
+ */
94
+ onChild: OnChildCallback<CustomLevels>;
95
+
96
+ /**
97
+ * Registers a listener function that is triggered when the level is changed.
98
+ * Note: When browserified, this functionality will only be available if the `events` module has been required elsewhere
99
+ * (e.g. if you're using streams in the browser). This allows for a trade-off between bundle size and functionality.
100
+ *
101
+ * @param event: only ever fires the `'level-change'` event
102
+ * @param listener: The listener is passed four arguments: `levelLabel`, `levelValue`, `previousLevelLabel`, `previousLevelValue`.
103
+ */
104
+ on(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
105
+ addListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
106
+ once(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
107
+ prependListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
108
+ prependOnceListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
109
+ removeListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
110
+
111
+ /**
112
+ * A utility method for determining if a given log level will write to the destination.
113
+ */
114
+ isLevelEnabled(level: pino.LevelWithSilentOrString): boolean;
115
+
116
+ /**
117
+ * Returns an object containing all the current bindings, cloned from the ones passed in via logger.child().
118
+ */
119
+ bindings(): pino.Bindings;
120
+
121
+ /**
122
+ * Adds to the bindings of this logger instance.
123
+ * Note: Does not overwrite bindings. Can potentially result in duplicate keys in log lines.
124
+ *
125
+ * @param bindings: an object of key-value pairs to include in log lines as properties.
126
+ */
127
+ setBindings(bindings: pino.Bindings): void;
128
+
129
+ /**
130
+ * Flushes the content of the buffer when using pino.destination({ sync: false }).
131
+ * call the callback when finished
132
+ */
133
+ flush(cb?: (err?: Error) => void): void;
134
+ }
135
+
136
+
137
+ declare namespace pino {
138
+ //// Exported types and interfaces
139
+
140
+ interface BaseLogger {
141
+ /**
142
+ * Set this property to the desired logging level. In order of priority, available levels are:
143
+ *
144
+ * - 'fatal'
145
+ * - 'error'
146
+ * - 'warn'
147
+ * - 'info'
148
+ * - 'debug'
149
+ * - 'trace'
150
+ *
151
+ * The logging level is a __minimum__ level. For instance if `logger.level` is `'info'` then all `'fatal'`, `'error'`, `'warn'`,
152
+ * and `'info'` logs will be enabled.
153
+ *
154
+ * You can pass `'silent'` to disable logging.
155
+ */
156
+ level: pino.LevelWithSilentOrString;
157
+
158
+ /**
159
+ * Log at `'fatal'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
160
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
161
+ *
162
+ * @typeParam T: the interface of the object being serialized. Default is object.
163
+ * @param obj: object to be serialized
164
+ * @param msg: the log message to write
165
+ * @param ...args: format string values when `msg` is a format string
166
+ */
167
+ fatal: pino.LogFn;
168
+ /**
169
+ * Log at `'error'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
170
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
171
+ *
172
+ * @typeParam T: the interface of the object being serialized. Default is object.
173
+ * @param obj: object to be serialized
174
+ * @param msg: the log message to write
175
+ * @param ...args: format string values when `msg` is a format string
176
+ */
177
+ error: pino.LogFn;
178
+ /**
179
+ * Log at `'warn'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
180
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
181
+ *
182
+ * @typeParam T: the interface of the object being serialized. Default is object.
183
+ * @param obj: object to be serialized
184
+ * @param msg: the log message to write
185
+ * @param ...args: format string values when `msg` is a format string
186
+ */
187
+ warn: pino.LogFn;
188
+ /**
189
+ * Log at `'info'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
190
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
191
+ *
192
+ * @typeParam T: the interface of the object being serialized. Default is object.
193
+ * @param obj: object to be serialized
194
+ * @param msg: the log message to write
195
+ * @param ...args: format string values when `msg` is a format string
196
+ */
197
+ info: pino.LogFn;
198
+ /**
199
+ * Log at `'debug'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
200
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
201
+ *
202
+ * @typeParam T: the interface of the object being serialized. Default is object.
203
+ * @param obj: object to be serialized
204
+ * @param msg: the log message to write
205
+ * @param ...args: format string values when `msg` is a format string
206
+ */
207
+ debug: pino.LogFn;
208
+ /**
209
+ * Log at `'trace'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
210
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
211
+ *
212
+ * @typeParam T: the interface of the object being serialized. Default is object.
213
+ * @param obj: object to be serialized
214
+ * @param msg: the log message to write
215
+ * @param ...args: format string values when `msg` is a format string
216
+ */
217
+ trace: pino.LogFn;
218
+ /**
219
+ * Noop function.
220
+ */
221
+ silent: pino.LogFn;
222
+ }
223
+
224
+ type Bindings = Record<string, any>;
225
+
226
+ type Level = "fatal" | "error" | "warn" | "info" | "debug" | "trace";
227
+ type LevelOrString = Level | (string & {});
228
+ type LevelWithSilent = pino.Level | "silent";
229
+ type LevelWithSilentOrString = LevelWithSilent | (string & {});
230
+
231
+ type SerializerFn = (value: any) => any;
232
+ type WriteFn = (o: object) => void;
233
+
234
+ type LevelChangeEventListener<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = (
235
+ lvl: LevelWithSilentOrString,
236
+ val: number,
237
+ prevLvl: LevelWithSilentOrString,
238
+ prevVal: number,
239
+ logger: Logger<CustomLevels, UseOnlyCustomLevels>
240
+ ) => void;
241
+
242
+ type LogDescriptor = Record<string, any>;
243
+
244
+ type Logger<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = BaseLogger & LoggerExtras<CustomLevels> & CustomLevelLogger<CustomLevels, UseOnlyCustomLevels>;
245
+
246
+ type SerializedError = pinoStdSerializers.SerializedError;
247
+ type SerializedResponse = pinoStdSerializers.SerializedResponse;
248
+ type SerializedRequest = pinoStdSerializers.SerializedRequest;
249
+
250
+
251
+ interface TransportTargetOptions<TransportOptions = Record<string, any>> {
252
+ target: string
253
+ options?: TransportOptions
254
+ level?: LevelWithSilentOrString
255
+ }
256
+
257
+ interface TransportBaseOptions<TransportOptions = Record<string, any>> {
258
+ options?: TransportOptions
259
+ worker?: WorkerOptions & { autoEnd?: boolean}
260
+ }
261
+
262
+ interface TransportSingleOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
263
+ target: string
264
+ }
265
+
266
+ interface TransportPipelineOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
267
+ pipeline: TransportSingleOptions<TransportOptions>[]
268
+ level?: LevelWithSilentOrString
269
+ }
270
+
271
+ interface TransportMultiOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
272
+ targets: readonly (TransportTargetOptions<TransportOptions>|TransportPipelineOptions<TransportOptions>)[],
273
+ levels?: Record<string, number>
274
+ dedupe?: boolean
275
+ }
276
+
277
+ interface MultiStreamOptions {
278
+ levels?: Record<string, number>
279
+ dedupe?: boolean
280
+ }
281
+
282
+ interface DestinationStream {
283
+ write(msg: string): void;
284
+ }
285
+
286
+ interface DestinationStreamHasMetadata {
287
+ [symbols.needsMetadataGsym]: true;
288
+ lastLevel: number;
289
+ lastTime: string;
290
+ lastMsg: string;
291
+ lastObj: object;
292
+ lastLogger: pino.Logger;
293
+ }
294
+
295
+ type DestinationStreamWithMetadata = DestinationStream & ({ [symbols.needsMetadataGsym]?: false } | DestinationStreamHasMetadata);
296
+
297
+ interface StreamEntry<TLevel = Level> {
298
+ stream: DestinationStream
299
+ level?: TLevel
300
+ }
301
+
302
+ interface MultiStreamRes<TOriginLevel = Level> {
303
+ write: (data: any) => void,
304
+ add: <TLevel = Level>(dest: StreamEntry<TLevel> | DestinationStream) => MultiStreamRes<TOriginLevel & TLevel>,
305
+ flushSync: () => void,
306
+ minLevel: number,
307
+ streams: StreamEntry<TOriginLevel>[],
308
+ clone<TLevel = Level>(level: TLevel): MultiStreamRes<TLevel>,
309
+ }
310
+
311
+ interface LevelMapping {
312
+ /**
313
+ * Returns the mappings of level names to their respective internal number representation.
314
+ */
315
+ values: { [level: string]: number };
316
+ /**
317
+ * Returns the mappings of level internal level numbers to their string representations.
318
+ */
319
+ labels: { [level: number]: string };
320
+ }
321
+
322
+ interface LogFn {
323
+ // TODO: why is this different from `obj: object` or `obj: any`?
324
+ /* tslint:disable:no-unnecessary-generics */
325
+ <T extends object>(obj: T, msg?: string, ...args: any[]): void;
326
+ (obj: unknown, msg?: string, ...args: any[]): void;
327
+ (msg: string, ...args: any[]): void;
328
+ }
329
+
330
+ interface LoggerOptions<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> {
331
+ transport?: TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions
332
+ /**
333
+ * Avoid error causes by circular references in the object tree. Default: `true`.
334
+ */
335
+ safe?: boolean;
336
+ /**
337
+ * The name of the logger. Default: `undefined`.
338
+ */
339
+ name?: string;
340
+ /**
341
+ * an object containing functions for custom serialization of objects.
342
+ * These functions should return an JSONifiable object and they should never throw. When logging an object,
343
+ * each top-level property matching the exact key of a serializer will be serialized using the defined serializer.
344
+ */
345
+ serializers?: { [key: string]: SerializerFn };
346
+ /**
347
+ * Enables or disables the inclusion of a timestamp in the log message. If a function is supplied, it must
348
+ * synchronously return a JSON string representation of the time. If set to `false`, no timestamp will be included in the output.
349
+ * See stdTimeFunctions for a set of available functions for passing in as a value for this option.
350
+ * Caution: any sort of formatted time will significantly slow down Pino's performance.
351
+ */
352
+ timestamp?: TimeFn | boolean;
353
+ /**
354
+ * One of the supported levels or `silent` to disable logging. Any other value defines a custom level and
355
+ * requires supplying a level value via `levelVal`. Default: 'info'.
356
+ */
357
+ level?: LevelWithSilentOrString;
358
+
359
+ /**
360
+ * Use this option to define additional logging levels.
361
+ * The keys of the object correspond the namespace of the log level, and the values should be the numerical value of the level.
362
+ */
363
+ customLevels?: { [level in CustomLevels]: number };
364
+
365
+ /**
366
+ * Use this option to only use defined `customLevels` and omit Pino's levels.
367
+ * Logger's default `level` must be changed to a value in `customLevels` in order to use `useOnlyCustomLevels`
368
+ * Warning: this option may not be supported by downstream transports.
369
+ */
370
+ useOnlyCustomLevels?: UseOnlyCustomLevels;
371
+
372
+ /**
373
+ * Use this option to define custom comparison of log levels.
374
+ * Useful to compare custom log levels or non-standard level values.
375
+ * Default: "ASC"
376
+ */
377
+ levelComparison?: "ASC" | "DESC" | ((current: number, expected: number) => boolean);
378
+
379
+ /**
380
+ * If provided, the `mixin` function is called each time one of the active logging methods
381
+ * is called. The function must synchronously return an object. The properties of the
382
+ * returned object will be added to the logged JSON.
383
+ */
384
+ mixin?: MixinFn<CustomLevels>;
385
+
386
+ /**
387
+ * If provided, the `mixinMergeStrategy` function is called each time one of the active
388
+ * logging methods is called. The first parameter is the value `mergeObject` or an empty object,
389
+ * the second parameter is the value resulting from `mixin()` or an empty object.
390
+ * The function must synchronously return an object.
391
+ */
392
+ mixinMergeStrategy?: MixinMergeStrategyFn
393
+
394
+ /**
395
+ * As an array, the redact option specifies paths that should have their values redacted from any log output.
396
+ *
397
+ * Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation.
398
+ *
399
+ * If an object is supplied, three options can be specified:
400
+ *
401
+ * paths (String[]): Required. An array of paths
402
+ * censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]'
403
+ * remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false
404
+ */
405
+ redact?: string[] | redactOptions;
406
+
407
+ /**
408
+ * When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`.
409
+ */
410
+ levelVal?: number;
411
+ /**
412
+ * The string key for the 'message' in the JSON object. Default: "msg".
413
+ */
414
+ messageKey?: string;
415
+ /**
416
+ * The string key for the 'error' in the JSON object. Default: "err".
417
+ */
418
+ errorKey?: string;
419
+ /**
420
+ * The string key to place any logged object under.
421
+ */
422
+ nestedKey?: string;
423
+ /**
424
+ * Enables logging. Default: `true`.
425
+ */
426
+ enabled?: boolean;
427
+ /**
428
+ * Browser only, see http://getpino.io/#/docs/browser.
429
+ */
430
+ browser?: {
431
+ /**
432
+ * The `asObject` option will create a pino-like log object instead of passing all arguments to a console
433
+ * method. When `write` is set, `asObject` will always be true.
434
+ *
435
+ * @example
436
+ * pino.info('hi') // creates and logs {msg: 'hi', level: 30, time: <ts>}
437
+ */
438
+ asObject?: boolean;
439
+ formatters?: {
440
+ /**
441
+ * Changes the shape of the log level.
442
+ * The default shape is { level: number }.
443
+ */
444
+ level?: (label: string, number: number) => object;
445
+ /**
446
+ * Changes the shape of the log object.
447
+ */
448
+ log?: (object: Record<string, unknown>) => Record<string, unknown>;
449
+ }
450
+ /**
451
+ * Instead of passing log messages to `console.log` they can be passed to a supplied function. If `write` is
452
+ * set to a single function, all logging objects are passed to this function. If `write` is an object, it
453
+ * can have methods that correspond to the levels. When a message is logged at a given level, the
454
+ * corresponding method is called. If a method isn't present, the logging falls back to using the `console`.
455
+ *
456
+ * @example
457
+ * const pino = require('pino')({
458
+ * browser: {
459
+ * write: (o) => {
460
+ * // do something with o
461
+ * }
462
+ * }
463
+ * })
464
+ *
465
+ * @example
466
+ * const pino = require('pino')({
467
+ * browser: {
468
+ * write: {
469
+ * info: function (o) {
470
+ * //process info log object
471
+ * },
472
+ * error: function (o) {
473
+ * //process error log object
474
+ * }
475
+ * }
476
+ * }
477
+ * })
478
+ */
479
+ write?:
480
+ | WriteFn
481
+ | ({
482
+ fatal?: WriteFn;
483
+ error?: WriteFn;
484
+ warn?: WriteFn;
485
+ info?: WriteFn;
486
+ debug?: WriteFn;
487
+ trace?: WriteFn;
488
+ } & { [logLevel: string]: WriteFn });
489
+
490
+ /**
491
+ * The serializers provided to `pino` are ignored by default in the browser, including the standard
492
+ * serializers provided with Pino. Since the default destination for log messages is the console, values
493
+ * such as `Error` objects are enhanced for inspection, which they otherwise wouldn't be if the Error
494
+ * serializer was enabled. We can turn all serializers on or we can selectively enable them via an array.
495
+ *
496
+ * When `serialize` is `true` the standard error serializer is also enabled (see
497
+ * {@link https://github.com/pinojs/pino/blob/master/docs/api.md#pino-stdserializers}). This is a global
498
+ * serializer which will apply to any `Error` objects passed to the logger methods.
499
+ *
500
+ * If `serialize` is an array the standard error serializer is also automatically enabled, it can be
501
+ * explicitly disabled by including a string in the serialize array: `!stdSerializers.err` (see example).
502
+ *
503
+ * The `serialize` array also applies to any child logger serializers (see
504
+ * {@link https://github.com/pinojs/pino/blob/master/docs/api.md#bindingsserializers-object} for how to
505
+ * set child-bound serializers).
506
+ *
507
+ * Unlike server pino the serializers apply to every object passed to the logger method, if the `asObject`
508
+ * option is `true`, this results in the serializers applying to the first object (as in server pino).
509
+ *
510
+ * For more info on serializers see
511
+ * {@link https://github.com/pinojs/pino/blob/master/docs/api.md#serializers-object}.
512
+ *
513
+ * @example
514
+ * const pino = require('pino')({
515
+ * browser: {
516
+ * serialize: true
517
+ * }
518
+ * })
519
+ *
520
+ * @example
521
+ * const pino = require('pino')({
522
+ * serializers: {
523
+ * custom: myCustomSerializer,
524
+ * another: anotherSerializer
525
+ * },
526
+ * browser: {
527
+ * serialize: ['custom']
528
+ * }
529
+ * })
530
+ * // following will apply myCustomSerializer to the custom property,
531
+ * // but will not apply anotherSerializer to another key
532
+ * pino.info({custom: 'a', another: 'b'})
533
+ *
534
+ * @example
535
+ * const pino = require('pino')({
536
+ * serializers: {
537
+ * custom: myCustomSerializer,
538
+ * another: anotherSerializer
539
+ * },
540
+ * browser: {
541
+ * serialize: ['!stdSerializers.err', 'custom'] //will not serialize Errors, will serialize `custom` keys
542
+ * }
543
+ * })
544
+ */
545
+ serialize?: boolean | string[];
546
+
547
+ /**
548
+ * Options for transmission of logs.
549
+ *
550
+ * @example
551
+ * const pino = require('pino')({
552
+ * browser: {
553
+ * transmit: {
554
+ * level: 'warn',
555
+ * send: function (level, logEvent) {
556
+ * if (level === 'warn') {
557
+ * // maybe send the logEvent to a separate endpoint
558
+ * // or maybe analyse the messages further before sending
559
+ * }
560
+ * // we could also use the `logEvent.level.value` property to determine
561
+ * // numerical value
562
+ * if (logEvent.level.value >= 50) { // covers error and fatal
563
+ *
564
+ * // send the logEvent somewhere
565
+ * }
566
+ * }
567
+ * }
568
+ * }
569
+ * })
570
+ */
571
+ transmit?: {
572
+ /**
573
+ * Specifies the minimum level (inclusive) of when the `send` function should be called, if not supplied
574
+ * the `send` function will be called based on the main logging `level` (set via `options.level`,
575
+ * defaulting to `info`).
576
+ */
577
+ level?: LevelOrString;
578
+ /**
579
+ * Remotely record log messages.
580
+ *
581
+ * @description Called after writing the log message.
582
+ */
583
+ send: (level: Level, logEvent: LogEvent) => void;
584
+ };
585
+ /**
586
+ * The disabled option will disable logging in browser if set to true, by default it is set to false.
587
+ *
588
+ * @example
589
+ * const pino = require('pino')({browser: {disabled: true}})
590
+ */
591
+ disabled?: boolean;
592
+ };
593
+ /**
594
+ * key-value object added as child logger to each log line. If set to null the base child logger is not added
595
+ */
596
+ base?: { [key: string]: any } | null;
597
+
598
+ /**
599
+ * An object containing functions for formatting the shape of the log lines.
600
+ * These functions should return a JSONifiable object and should never throw.
601
+ * These functions allow for full customization of the resulting log lines.
602
+ * For example, they can be used to change the level key name or to enrich the default metadata.
603
+ */
604
+ formatters?: {
605
+ /**
606
+ * Changes the shape of the log level.
607
+ * The default shape is { level: number }.
608
+ * The function takes two arguments, the label of the level (e.g. 'info') and the numeric value (e.g. 30).
609
+ */
610
+ level?: (label: string, number: number) => object;
611
+ /**
612
+ * Changes the shape of the bindings.
613
+ * The default shape is { pid, hostname }.
614
+ * The function takes a single argument, the bindings object.
615
+ * It will be called every time a child logger is created.
616
+ */
617
+ bindings?: (bindings: Bindings) => object;
618
+ /**
619
+ * Changes the shape of the log object.
620
+ * This function will be called every time one of the log methods (such as .info) is called.
621
+ * All arguments passed to the log method, except the message, will be pass to this function.
622
+ * By default it does not change the shape of the log object.
623
+ */
624
+ log?: (object: Record<string, unknown>) => Record<string, unknown>;
625
+ };
626
+
627
+ /**
628
+ * A string that would be prefixed to every message (and child message)
629
+ */
630
+ msgPrefix?: string
631
+
632
+ /**
633
+ * An object mapping to hook functions. Hook functions allow for customizing internal logger operations.
634
+ * Hook functions must be synchronous functions.
635
+ */
636
+ hooks?: {
637
+ /**
638
+ * Allows for manipulating the parameters passed to logger methods. The signature for this hook is
639
+ * logMethod (args, method, level) {}, where args is an array of the arguments that were passed to the
640
+ * log method and method is the log method itself, and level is the log level. This hook must invoke the method function by
641
+ * using apply, like so: method.apply(this, newArgumentsArray).
642
+ */
643
+ logMethod?: (this: Logger, args: Parameters<LogFn>, method: LogFn, level: number) => void;
644
+
645
+ /**
646
+ * Allows for manipulating the stringified JSON log output just before writing to various transports.
647
+ * This function must return a string and must be valid JSON.
648
+ */
649
+ streamWrite?: (s: string) => string;
650
+ };
651
+
652
+ /**
653
+ * Stringification limit at a specific nesting depth when logging circular object. Default: `5`.
654
+ */
655
+ depthLimit?: number
656
+
657
+ /**
658
+ * Stringification limit of properties/elements when logging a specific object/array with circular references. Default: `100`.
659
+ */
660
+ edgeLimit?: number
661
+
662
+ /**
663
+ * Optional child creation callback.
664
+ */
665
+ onChild?: OnChildCallback<CustomLevels>;
666
+
667
+ /**
668
+ * logs newline delimited JSON with `\r\n` instead of `\n`. Default: `false`.
669
+ */
670
+ crlf?: boolean;
671
+ }
672
+
673
+ interface ChildLoggerOptions<CustomLevels extends string = never> {
674
+ level?: LevelOrString;
675
+ serializers?: { [key: string]: SerializerFn };
676
+ customLevels?: { [level in CustomLevels]: number };
677
+ formatters?: {
678
+ level?: (label: string, number: number) => object;
679
+ bindings?: (bindings: Bindings) => object;
680
+ log?: (object: object) => object;
681
+ };
682
+ redact?: string[] | redactOptions;
683
+ msgPrefix?: string
684
+ }
685
+
686
+ /**
687
+ * A data structure representing a log message, it represents the arguments passed to a logger statement, the level
688
+ * at which they were logged and the hierarchy of child bindings.
689
+ *
690
+ * @description By default serializers are not applied to log output in the browser, but they will always be applied
691
+ * to `messages` and `bindings` in the `logEvent` object. This allows us to ensure a consistent format for all
692
+ * values between server and client.
693
+ */
694
+ interface LogEvent {
695
+ /**
696
+ * Unix epoch timestamp in milliseconds, the time is taken from the moment the logger method is called.
697
+ */
698
+ ts: number;
699
+ /**
700
+ * All arguments passed to logger method, (for instance `logger.info('a', 'b', 'c')` would result in `messages`
701
+ * array `['a', 'b', 'c']`).
702
+ */
703
+ messages: any[];
704
+ /**
705
+ * Represents each child logger (if any), and the relevant bindings.
706
+ *
707
+ * @description For instance, given `logger.child({a: 1}).child({b: 2}).info({c: 3})`, the bindings array would
708
+ * hold `[{a: 1}, {b: 2}]` and the `messages` array would be `[{c: 3}]`. The `bindings` are ordered according to
709
+ * their position in the child logger hierarchy, with the lowest index being the top of the hierarchy.
710
+ */
711
+ bindings: Bindings[];
712
+ /**
713
+ * Holds the `label` (for instance `info`), and the corresponding numerical `value` (for instance `30`).
714
+ * This could be important in cases where client side level values and labels differ from server side.
715
+ */
716
+ level: {
717
+ label: string;
718
+ value: number;
719
+ };
720
+ }
721
+
722
+
723
+
724
+ //// Top level variable (const) exports
725
+
726
+ /**
727
+ * Provides functions for serializing objects common to many projects.
728
+ */
729
+ export const stdSerializers: typeof pinoStdSerializers;
730
+
731
+ /**
732
+ * Holds the current log format version (as output in the v property of each log record).
733
+ */
734
+ export const levels: LevelMapping;
735
+ export const symbols: {
736
+ readonly setLevelSym: unique symbol;
737
+ readonly getLevelSym: unique symbol;
738
+ readonly levelValSym: unique symbol;
739
+ readonly useLevelLabelsSym: unique symbol;
740
+ readonly mixinSym: unique symbol;
741
+ readonly lsCacheSym: unique symbol;
742
+ readonly chindingsSym: unique symbol;
743
+ readonly parsedChindingsSym: unique symbol;
744
+ readonly asJsonSym: unique symbol;
745
+ readonly writeSym: unique symbol;
746
+ readonly serializersSym: unique symbol;
747
+ readonly redactFmtSym: unique symbol;
748
+ readonly timeSym: unique symbol;
749
+ readonly timeSliceIndexSym: unique symbol;
750
+ readonly streamSym: unique symbol;
751
+ readonly stringifySym: unique symbol;
752
+ readonly stringifySafeSym: unique symbol;
753
+ readonly stringifiersSym: unique symbol;
754
+ readonly endSym: unique symbol;
755
+ readonly formatOptsSym: unique symbol;
756
+ readonly messageKeySym: unique symbol;
757
+ readonly errorKeySym: unique symbol;
758
+ readonly nestedKeySym: unique symbol;
759
+ readonly wildcardFirstSym: unique symbol;
760
+ readonly needsMetadataGsym: unique symbol;
761
+ readonly useOnlyCustomLevelsSym: unique symbol;
762
+ readonly formattersSym: unique symbol;
763
+ readonly hooksSym: unique symbol;
764
+ };
765
+
766
+ /**
767
+ * Exposes the Pino package version. Also available on the logger instance.
768
+ */
769
+ export const version: string;
770
+
771
+ /**
772
+ * Provides functions for generating the timestamp property in the log output. You can set the `timestamp` option during
773
+ * initialization to one of these functions to adjust the output format. Alternatively, you can specify your own time function.
774
+ * A time function must synchronously return a string that would be a valid component of a JSON string. For example,
775
+ * the default function returns a string like `,"time":1493426328206`.
776
+ */
777
+ export const stdTimeFunctions: {
778
+ /**
779
+ * The default time function for Pino. Returns a string like `,"time":1493426328206`.
780
+ */
781
+ epochTime: TimeFn;
782
+ /*
783
+ * Returns the seconds since Unix epoch
784
+ */
785
+ unixTime: TimeFn;
786
+ /**
787
+ * Returns an empty string. This function is used when the `timestamp` option is set to `false`.
788
+ */
789
+ nullTime: TimeFn;
790
+ /*
791
+ * Returns ISO 8601-formatted time in UTC
792
+ */
793
+ isoTime: TimeFn;
794
+ };
795
+
796
+ //// Exported functions
797
+
798
+ /**
799
+ * Create a Pino Destination instance: a stream-like object with significantly more throughput (over 30%) than a standard Node.js stream.
800
+ * @param [dest]: The `destination` parameter, can be a file descriptor, a file path, or an object with `dest` property pointing to a fd or path.
801
+ * An ordinary Node.js `stream` file descriptor can be passed as the destination (such as the result of `fs.createWriteStream`)
802
+ * but for peak log writing performance, it is strongly recommended to use `pino.destination` to create the destination stream.
803
+ * @returns A Sonic-Boom stream to be used as destination for the pino function
804
+ */
805
+ export function destination(
806
+ dest?: number | object | string | DestinationStream | NodeJS.WritableStream | SonicBoomOpts,
807
+ ): SonicBoom;
808
+
809
+ export function transport<TransportOptions = Record<string, any>>(
810
+ options: TransportSingleOptions<TransportOptions> | TransportMultiOptions<TransportOptions> | TransportPipelineOptions<TransportOptions>
811
+ ): ThreadStream
812
+
813
+ export function multistream<TLevel = Level>(
814
+ streamsArray: (DestinationStream | StreamEntry<TLevel>)[] | DestinationStream | StreamEntry<TLevel>,
815
+ opts?: MultiStreamOptions
816
+ ): MultiStreamRes<TLevel>
817
+ }
818
+
819
+ //// Callable default export
820
+
821
+ /**
822
+ * @param [optionsOrStream]: an options object or a writable stream where the logs will be written. It can also receive some log-line metadata, if the
823
+ * relative protocol is enabled. Default: process.stdout
824
+ * @returns a new logger instance.
825
+ */
826
+ declare function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(optionsOrStream?: LoggerOptions<CustomLevels, UseOnlyCustomLevels> | DestinationStream): Logger<CustomLevels, UseOnlyCustomLevels>;
827
+
828
+ /**
829
+ * @param [options]: an options object
830
+ * @param [stream]: a writable stream where the logs will be written. It can also receive some log-line metadata, if the
831
+ * relative protocol is enabled. Default: process.stdout
832
+ * @returns a new logger instance.
833
+ */
834
+ declare function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(options: LoggerOptions<CustomLevels, UseOnlyCustomLevels>, stream?: DestinationStream | undefined): Logger<CustomLevels, UseOnlyCustomLevels>;
835
+
836
+
837
+ // Pass through all the top-level exports, allows `import {version} from "pino"`
838
+ // Constants and functions
839
+ export const destination: typeof pino.destination;
840
+ export const transport: typeof pino.transport;
841
+ export const multistream: typeof pino.multistream;
842
+ export const levels: typeof pino.levels;
843
+ export const stdSerializers: typeof pino.stdSerializers;
844
+ export const stdTimeFunctions: typeof pino.stdTimeFunctions;
845
+ export const symbols: typeof pino.symbols;
846
+ export const version: typeof pino.version;
847
+
848
+ // Types
849
+ export type Bindings = pino.Bindings;
850
+ export type DestinationStreamWithMetadata = pino.DestinationStreamWithMetadata;
851
+ export type Level = pino.Level;
852
+ export type LevelOrString = pino.LevelOrString;
853
+ export type LevelWithSilent = pino.LevelWithSilent;
854
+ export type LevelWithSilentOrString = pino.LevelWithSilentOrString;
855
+ export type LevelChangeEventListener<CustomLevels extends string> = pino.LevelChangeEventListener<CustomLevels>;
856
+ export type LogDescriptor = pino.LogDescriptor;
857
+ export type Logger<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = pino.Logger<CustomLevels, UseOnlyCustomLevels>;
858
+ export type SerializedError = pino.SerializedError;
859
+ export type SerializerFn = pino.SerializerFn;
860
+ export type SerializedRequest = pino.SerializedRequest;
861
+ export type SerializedResponse = pino.SerializedResponse;
862
+ export type WriteFn = pino.WriteFn;
863
+
864
+ // Interfaces
865
+ export interface BaseLogger extends pino.BaseLogger {}
866
+ export interface ChildLoggerOptions<CustomLevels extends string = never> extends pino.ChildLoggerOptions<CustomLevels> {}
867
+ export interface DestinationStream extends pino.DestinationStream {}
868
+ export interface LevelMapping extends pino.LevelMapping {}
869
+ export interface LogEvent extends pino.LogEvent {}
870
+ export interface LogFn extends pino.LogFn {}
871
+ export interface LoggerOptions<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> extends pino.LoggerOptions<CustomLevels, UseOnlyCustomLevels> {}
872
+ export interface MultiStreamOptions extends pino.MultiStreamOptions {}
873
+ export interface MultiStreamRes<TLevel = Level> extends pino.MultiStreamRes<TLevel> {}
874
+ export interface StreamEntry<TLevel = Level> extends pino.StreamEntry<TLevel> {}
875
+ export interface TransportBaseOptions extends pino.TransportBaseOptions {}
876
+ export interface TransportMultiOptions extends pino.TransportMultiOptions {}
877
+ export interface TransportPipelineOptions extends pino.TransportPipelineOptions {}
878
+ export interface TransportSingleOptions extends pino.TransportSingleOptions {}
879
+ export interface TransportTargetOptions extends pino.TransportTargetOptions {}
880
+
881
+ // Bundle all top level exports into a namespace, then export namespace both
882
+ // as default (`import pino from "pino"`) and named variable
883
+ // (`import {pino} from "pino"`).
884
+ export { pino as default, pino };
885
+ // Export just the type side of the namespace as "P", allows
886
+ // `import {P} from "pino"; const log: P.Logger;`.
887
+ // (Legacy support for early 7.x releases, remove in 8.x.)
888
+ export type { pino as P };
889
+