1 | // Type definitions for pino-pretty 4.7
|
2 | // Project: https://github.com/pinojs/pino-pretty#readme
|
3 | // Definitions by: Adam Vigneaux <https://github.com/AdamVig>
|
4 | // Minimum TypeScript Version: 3.0
|
5 |
|
6 | type LogDescriptor = Record<string, unknown>;
|
7 |
|
8 | declare function PinoPretty(options: PrettyOptions_): PinoPretty.Prettifier;
|
9 |
|
10 | interface PrettyOptions_ {
|
11 | /**
|
12 | * Hide objects from output (but not error object).
|
13 | * @default false
|
14 | */
|
15 | hideObject?: boolean;
|
16 | /**
|
17 | * Translate the epoch time value into a human readable date and time string. This flag also can set the format
|
18 | * string to apply when translating the date to human readable format. For a list of available pattern letters
|
19 | * see the {@link https://www.npmjs.com/package/dateformat|dateformat documentation}.
|
20 | * - The default format is `yyyy-mm-dd HH:MM:ss.l o` in UTC.
|
21 | * - Requires a `SYS:` prefix to translate time to the local system's timezone. Use the shortcut `SYS:standard`
|
22 | * to translate time to `yyyy-mm-dd HH:MM:ss.l o` in system timezone.
|
23 | * @default false
|
24 | */
|
25 | translateTime?: boolean | string;
|
26 | /**
|
27 | * If set to true, it will print the name of the log level as the first field in the log line.
|
28 | * @default false
|
29 | */
|
30 | levelFirst?: boolean;
|
31 | /**
|
32 | * Define the key that contains the level of the log.
|
33 | * @default "level"
|
34 | */
|
35 | levelKey?: string;
|
36 | /**
|
37 | * Output the log level using the specified label.
|
38 | * @default "levelLabel"
|
39 | */
|
40 | levelLabel?: string;
|
41 | /**
|
42 | * The key in the JSON object to use as the highlighted message.
|
43 | * @default "msg"
|
44 | */
|
45 | messageKey?: string;
|
46 | /**
|
47 | * Print each log message on a single line (errors will still be multi-line).
|
48 | * @default false
|
49 | */
|
50 | singleLine?: boolean;
|
51 | /**
|
52 | * The key in the JSON object to use for timestamp display.
|
53 | * @default "time"
|
54 | */
|
55 | timestampKey?: string;
|
56 | /**
|
57 | * Format output of message, e.g. {level} - {pid} will output message: INFO - 1123
|
58 | * @default false
|
59 | *
|
60 | * @example
|
61 | * ```typescript
|
62 | * {
|
63 | * messageFormat: (log, messageKey) => {
|
64 | * const message = log[messageKey];
|
65 | * if (log.requestId) return `[${log.requestId}] ${message}`;
|
66 | * return message;
|
67 | * }
|
68 | * }
|
69 | * ```
|
70 | */
|
71 | messageFormat?: false | string | PinoPretty.MessageFormatFunc;
|
72 | /**
|
73 | * If set to true, will add color information to the formatted output message.
|
74 | * @default false
|
75 | */
|
76 | colorize?: boolean;
|
77 | /**
|
78 | * Appends carriage return and line feed, instead of just a line feed, to the formatted log line.
|
79 | * @default false
|
80 | */
|
81 | crlf?: boolean;
|
82 | /**
|
83 | * Define the log keys that are associated with error like objects.
|
84 | * @default ["err", "error"]
|
85 | */
|
86 | errorLikeObjectKeys?: string[];
|
87 | /**
|
88 | * When formatting an error object, display this list of properties.
|
89 | * The list should be a comma separated list of properties.
|
90 | * @default ""
|
91 | */
|
92 | errorProps?: string;
|
93 | /**
|
94 | * Specify a search pattern according to {@link http://jmespath.org|jmespath}
|
95 | */
|
96 | search?: string;
|
97 | /**
|
98 | * Ignore one or several keys.
|
99 | * @example "time,hostname"
|
100 | */
|
101 | ignore?: string;
|
102 | }
|
103 |
|
104 | declare namespace PinoPretty {
|
105 | type Prettifier = (inputData: string | object) => string;
|
106 | type MessageFormatFunc = (log: LogDescriptor, messageKey: string, levelLabel: string) => string;
|
107 | type PrettyOptions = PrettyOptions_
|
108 | }
|
109 |
|
110 | export default PinoPretty;
|
111 | export { PinoPretty, PrettyOptions_ as PrettyOptions }
|