1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
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 |
|
26 |
|
27 |
|
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 |
|
37 |
|
38 | customLevels: { [level in CustomLevels]: number };
|
39 | |
40 |
|
41 |
|
42 | useOnlyCustomLevels: UseOnlyCustomLevels;
|
43 | } & {
|
44 |
|
45 | [K in Exclude<pino.Level, CustomLevels>]: UseOnlyCustomLevels extends true ? never : pino.LogFn;
|
46 | } & {
|
47 | [level in CustomLevels]: pino.LogFn;
|
48 | };
|
49 |
|
50 |
|
51 |
|
52 |
|
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 |
|
314 |
|
315 | values: { [level: string]: number };
|
316 | |
317 |
|
318 |
|
319 | labels: { [level: number]: string };
|
320 | }
|
321 |
|
322 | interface LogFn {
|
323 |
|
324 |
|
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 |
|
334 |
|
335 | safe?: boolean;
|
336 | |
337 |
|
338 |
|
339 | name?: string;
|
340 | |
341 |
|
342 |
|
343 |
|
344 |
|
345 | serializers?: { [key: string]: SerializerFn };
|
346 | |
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 | timestamp?: TimeFn | boolean;
|
353 | |
354 |
|
355 |
|
356 |
|
357 | level?: LevelWithSilentOrString;
|
358 |
|
359 | |
360 |
|
361 |
|
362 |
|
363 | customLevels?: { [level in CustomLevels]: number };
|
364 |
|
365 | |
366 |
|
367 |
|
368 |
|
369 |
|
370 | useOnlyCustomLevels?: UseOnlyCustomLevels;
|
371 |
|
372 | |
373 |
|
374 |
|
375 |
|
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 |
|
447 |
|
448 | log?: (object: Record<string, unknown>) => Record<string, unknown>;
|
449 | }
|
450 | |
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
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 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 | serialize?: boolean | string[];
|
546 |
|
547 | |
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 | transmit?: {
|
572 | |
573 |
|
574 |
|
575 |
|
576 |
|
577 | level?: LevelOrString;
|
578 | |
579 |
|
580 |
|
581 |
|
582 |
|
583 | send: (level: Level, logEvent: LogEvent) => void;
|
584 | };
|
585 | |
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 | disabled?: boolean;
|
592 | };
|
593 | |
594 |
|
595 |
|
596 | base?: { [key: string]: any } | null;
|
597 |
|
598 | |
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 | formatters?: {
|
605 | |
606 |
|
607 |
|
608 |
|
609 |
|
610 | level?: (label: string, number: number) => object;
|
611 | |
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 | bindings?: (bindings: Bindings) => object;
|
618 | |
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 | log?: (object: Record<string, unknown>) => Record<string, unknown>;
|
625 | };
|
626 |
|
627 | |
628 |
|
629 |
|
630 | msgPrefix?: string
|
631 |
|
632 | |
633 |
|
634 |
|
635 |
|
636 | hooks?: {
|
637 | |
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 | logMethod?: (this: Logger, args: Parameters<LogFn>, method: LogFn, level: number) => void;
|
644 | };
|
645 |
|
646 | |
647 |
|
648 |
|
649 | depthLimit?: number
|
650 |
|
651 | |
652 |
|
653 |
|
654 | edgeLimit?: number
|
655 |
|
656 | |
657 |
|
658 |
|
659 | onChild?: OnChildCallback<CustomLevels>;
|
660 |
|
661 | |
662 |
|
663 |
|
664 | crlf?: boolean;
|
665 | }
|
666 |
|
667 | interface ChildLoggerOptions<CustomLevels extends string = never> {
|
668 | level?: LevelOrString;
|
669 | serializers?: { [key: string]: SerializerFn };
|
670 | customLevels?: { [level in CustomLevels]: number };
|
671 | formatters?: {
|
672 | level?: (label: string, number: number) => object;
|
673 | bindings?: (bindings: Bindings) => object;
|
674 | log?: (object: object) => object;
|
675 | };
|
676 | redact?: string[] | redactOptions;
|
677 | msgPrefix?: string
|
678 | }
|
679 |
|
680 | |
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 | interface LogEvent {
|
689 | |
690 |
|
691 |
|
692 | ts: number;
|
693 | |
694 |
|
695 |
|
696 |
|
697 | messages: any[];
|
698 | |
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 | bindings: Bindings[];
|
706 | |
707 |
|
708 |
|
709 |
|
710 | level: {
|
711 | label: string;
|
712 | value: number;
|
713 | };
|
714 | }
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 | |
721 |
|
722 |
|
723 | export const stdSerializers: typeof pinoStdSerializers;
|
724 |
|
725 | |
726 |
|
727 |
|
728 | export const levels: LevelMapping;
|
729 | export const symbols: {
|
730 | readonly setLevelSym: unique symbol;
|
731 | readonly getLevelSym: unique symbol;
|
732 | readonly levelValSym: unique symbol;
|
733 | readonly useLevelLabelsSym: unique symbol;
|
734 | readonly mixinSym: unique symbol;
|
735 | readonly lsCacheSym: unique symbol;
|
736 | readonly chindingsSym: unique symbol;
|
737 | readonly parsedChindingsSym: unique symbol;
|
738 | readonly asJsonSym: unique symbol;
|
739 | readonly writeSym: unique symbol;
|
740 | readonly serializersSym: unique symbol;
|
741 | readonly redactFmtSym: unique symbol;
|
742 | readonly timeSym: unique symbol;
|
743 | readonly timeSliceIndexSym: unique symbol;
|
744 | readonly streamSym: unique symbol;
|
745 | readonly stringifySym: unique symbol;
|
746 | readonly stringifySafeSym: unique symbol;
|
747 | readonly stringifiersSym: unique symbol;
|
748 | readonly endSym: unique symbol;
|
749 | readonly formatOptsSym: unique symbol;
|
750 | readonly messageKeySym: unique symbol;
|
751 | readonly errorKeySym: unique symbol;
|
752 | readonly nestedKeySym: unique symbol;
|
753 | readonly wildcardFirstSym: unique symbol;
|
754 | readonly needsMetadataGsym: unique symbol;
|
755 | readonly useOnlyCustomLevelsSym: unique symbol;
|
756 | readonly formattersSym: unique symbol;
|
757 | readonly hooksSym: unique symbol;
|
758 | };
|
759 |
|
760 | |
761 |
|
762 |
|
763 | export const version: string;
|
764 |
|
765 | |
766 |
|
767 |
|
768 |
|
769 |
|
770 |
|
771 | export const stdTimeFunctions: {
|
772 | |
773 |
|
774 |
|
775 | epochTime: TimeFn;
|
776 | |
777 |
|
778 |
|
779 | unixTime: TimeFn;
|
780 | |
781 |
|
782 |
|
783 | nullTime: TimeFn;
|
784 | |
785 |
|
786 |
|
787 | isoTime: TimeFn;
|
788 | };
|
789 |
|
790 |
|
791 |
|
792 | |
793 |
|
794 |
|
795 |
|
796 |
|
797 |
|
798 |
|
799 | export function destination(
|
800 | dest?: number | object | string | DestinationStream | NodeJS.WritableStream | SonicBoomOpts,
|
801 | ): SonicBoom;
|
802 |
|
803 | export function transport<TransportOptions = Record<string, any>>(
|
804 | options: TransportSingleOptions<TransportOptions> | TransportMultiOptions<TransportOptions> | TransportPipelineOptions<TransportOptions>
|
805 | ): ThreadStream
|
806 |
|
807 | export function multistream<TLevel = Level>(
|
808 | streamsArray: (DestinationStream | StreamEntry<TLevel>)[] | DestinationStream | StreamEntry<TLevel>,
|
809 | opts?: MultiStreamOptions
|
810 | ): MultiStreamRes<TLevel>
|
811 | }
|
812 |
|
813 | //// Callable default export
|
814 |
|
815 | /**
|
816 | * @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
|
817 | * relative protocol is enabled. Default: process.stdout
|
818 | * @returns a new logger instance.
|
819 | */
|
820 | declare function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(optionsOrStream?: LoggerOptions<CustomLevels, UseOnlyCustomLevels> | DestinationStream): Logger<CustomLevels, UseOnlyCustomLevels>;
|
821 |
|
822 | /**
|
823 | * @param [options]: an options object
|
824 | * @param [stream]: a writable stream where the logs will be written. It can also receive some log-line metadata, if the
|
825 | * relative protocol is enabled. Default: process.stdout
|
826 | * @returns a new logger instance.
|
827 | */
|
828 | declare function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(options: LoggerOptions<CustomLevels, UseOnlyCustomLevels>, stream?: DestinationStream | undefined): Logger<CustomLevels, UseOnlyCustomLevels>;
|
829 |
|
830 |
|
831 | // Pass through all the top-level exports, allows `import {version} from "pino"`
|
832 | // Constants and functions
|
833 | export const destination: typeof pino.destination;
|
834 | export const transport: typeof pino.transport;
|
835 | export const multistream: typeof pino.multistream;
|
836 | export const levels: typeof pino.levels;
|
837 | export const stdSerializers: typeof pino.stdSerializers;
|
838 | export const stdTimeFunctions: typeof pino.stdTimeFunctions;
|
839 | export const symbols: typeof pino.symbols;
|
840 | export const version: typeof pino.version;
|
841 |
|
842 |
|
843 | export type Bindings = pino.Bindings;
|
844 | export type DestinationStreamWithMetadata = pino.DestinationStreamWithMetadata;
|
845 | export type Level = pino.Level;
|
846 | export type LevelOrString = pino.LevelOrString;
|
847 | export type LevelWithSilent = pino.LevelWithSilent;
|
848 | export type LevelWithSilentOrString = pino.LevelWithSilentOrString;
|
849 | export type LevelChangeEventListener<CustomLevels extends string> = pino.LevelChangeEventListener<CustomLevels>;
|
850 | export type LogDescriptor = pino.LogDescriptor;
|
851 | export type Logger<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = pino.Logger<CustomLevels, UseOnlyCustomLevels>;
|
852 | export type SerializedError = pino.SerializedError;
|
853 | export type SerializerFn = pino.SerializerFn;
|
854 | export type SerializedRequest = pino.SerializedRequest;
|
855 | export type SerializedResponse = pino.SerializedResponse;
|
856 | export type WriteFn = pino.WriteFn;
|
857 |
|
858 |
|
859 | export interface BaseLogger extends pino.BaseLogger {}
|
860 | export interface ChildLoggerOptions<CustomLevels extends string = never> extends pino.ChildLoggerOptions<CustomLevels> {}
|
861 | export interface DestinationStream extends pino.DestinationStream {}
|
862 | export interface LevelMapping extends pino.LevelMapping {}
|
863 | export interface LogEvent extends pino.LogEvent {}
|
864 | export interface LogFn extends pino.LogFn {}
|
865 | export interface LoggerOptions<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> extends pino.LoggerOptions<CustomLevels, UseOnlyCustomLevels> {}
|
866 | export interface MultiStreamOptions extends pino.MultiStreamOptions {}
|
867 | export interface MultiStreamRes<TLevel = Level> extends pino.MultiStreamRes<TLevel> {}
|
868 | export interface StreamEntry<TLevel = Level> extends pino.StreamEntry<TLevel> {}
|
869 | export interface TransportBaseOptions extends pino.TransportBaseOptions {}
|
870 | export interface TransportMultiOptions extends pino.TransportMultiOptions {}
|
871 | export interface TransportPipelineOptions extends pino.TransportPipelineOptions {}
|
872 | export interface TransportSingleOptions extends pino.TransportSingleOptions {}
|
873 | export interface TransportTargetOptions extends pino.TransportTargetOptions {}
|
874 |
|
875 |
|
876 |
|
877 |
|
878 | export { pino as default, pino };
|
879 |
|
880 |
|
881 |
|
882 | export type { pino as P };
|
883 |
|