18
18
19
19
import type { EventEmitter } from "events" ;
20
20
// @ts -ignore -- gracefully falls back to `any` if not installed
21
- import type { PrettyOptions } from "pino-pretty" ;
21
+ import type { PrettyOptions as PinoPrettyOptions } from "pino-pretty" ;
22
22
import type { SonicBoom , SonicBoomOpts } from "sonic-boom" ;
23
23
import type { WorkerOptions } from "worker_threads" ;
24
24
@@ -27,9 +27,6 @@ import * as pinoStdSerializers from "pino-std-serializers";
27
27
28
28
//// Non-exported types and interfaces
29
29
30
- type SerializerFn = ( value : any ) => any ;
31
- type WriteFn = ( o : object ) => void ;
32
-
33
30
// ToDo https://github.com/pinojs/thread-stream/issues/24
34
31
type ThreadStream = any
35
32
@@ -42,90 +39,6 @@ interface redactOptions {
42
39
remove ?: boolean ;
43
40
}
44
41
45
- interface BaseLogger {
46
- /**
47
- * Set this property to the desired logging level. In order of priority, available levels are:
48
- *
49
- * - 'fatal'
50
- * - 'error'
51
- * - 'warn'
52
- * - 'info'
53
- * - 'debug'
54
- * - 'trace'
55
- *
56
- * The logging level is a __minimum__ level. For instance if `logger.level` is `'info'` then all `'fatal'`, `'error'`, `'warn'`,
57
- * and `'info'` logs will be enabled.
58
- *
59
- * You can pass `'silent'` to disable logging.
60
- */
61
- level : pino . LevelWithSilent | string ;
62
-
63
- /**
64
- * Log at `'fatal'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
65
- * If more args follows `msg`, these will be used to format `msg` using `util.format`.
66
- *
67
- * @typeParam T: the interface of the object being serialized. Default is object.
68
- * @param obj: object to be serialized
69
- * @param msg: the log message to write
70
- * @param ...args: format string values when `msg` is a format string
71
- */
72
- fatal : pino . LogFn ;
73
- /**
74
- * Log at `'error'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
75
- * If more args follows `msg`, these will be used to format `msg` using `util.format`.
76
- *
77
- * @typeParam T: the interface of the object being serialized. Default is object.
78
- * @param obj: object to be serialized
79
- * @param msg: the log message to write
80
- * @param ...args: format string values when `msg` is a format string
81
- */
82
- error : pino . LogFn ;
83
- /**
84
- * Log at `'warn'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
85
- * If more args follows `msg`, these will be used to format `msg` using `util.format`.
86
- *
87
- * @typeParam T: the interface of the object being serialized. Default is object.
88
- * @param obj: object to be serialized
89
- * @param msg: the log message to write
90
- * @param ...args: format string values when `msg` is a format string
91
- */
92
- warn : pino . LogFn ;
93
- /**
94
- * Log at `'info'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
95
- * If more args follows `msg`, these will be used to format `msg` using `util.format`.
96
- *
97
- * @typeParam T: the interface of the object being serialized. Default is object.
98
- * @param obj: object to be serialized
99
- * @param msg: the log message to write
100
- * @param ...args: format string values when `msg` is a format string
101
- */
102
- info : pino . LogFn ;
103
- /**
104
- * Log at `'debug'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
105
- * If more args follows `msg`, these will be used to format `msg` using `util.format`.
106
- *
107
- * @typeParam T: the interface of the object being serialized. Default is object.
108
- * @param obj: object to be serialized
109
- * @param msg: the log message to write
110
- * @param ...args: format string values when `msg` is a format string
111
- */
112
- debug : pino . LogFn ;
113
- /**
114
- * Log at `'trace'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
115
- * If more args follows `msg`, these will be used to format `msg` using `util.format`.
116
- *
117
- * @typeParam T: the interface of the object being serialized. Default is object.
118
- * @param obj: object to be serialized
119
- * @param msg: the log message to write
120
- * @param ...args: format string values when `msg` is a format string
121
- */
122
- trace : pino . LogFn ;
123
- /**
124
- * Noop function.
125
- */
126
- silent : pino . LogFn ;
127
- }
128
-
129
42
interface LoggerExtras extends EventEmitter {
130
43
/**
131
44
* Exposes the Pino package version. Also available on the exported pino function.
@@ -192,10 +105,98 @@ interface LoggerExtras extends EventEmitter {
192
105
193
106
declare namespace pino {
194
107
//// Exported types and interfaces
108
+
109
+ interface BaseLogger {
110
+ /**
111
+ * Set this property to the desired logging level. In order of priority, available levels are:
112
+ *
113
+ * - 'fatal'
114
+ * - 'error'
115
+ * - 'warn'
116
+ * - 'info'
117
+ * - 'debug'
118
+ * - 'trace'
119
+ *
120
+ * The logging level is a __minimum__ level. For instance if `logger.level` is `'info'` then all `'fatal'`, `'error'`, `'warn'`,
121
+ * and `'info'` logs will be enabled.
122
+ *
123
+ * You can pass `'silent'` to disable logging.
124
+ */
125
+ level : pino . LevelWithSilent | string ;
126
+
127
+ /**
128
+ * Log at `'fatal'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
129
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
130
+ *
131
+ * @typeParam T: the interface of the object being serialized. Default is object.
132
+ * @param obj: object to be serialized
133
+ * @param msg: the log message to write
134
+ * @param ...args: format string values when `msg` is a format string
135
+ */
136
+ fatal : pino . LogFn ;
137
+ /**
138
+ * Log at `'error'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
139
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
140
+ *
141
+ * @typeParam T: the interface of the object being serialized. Default is object.
142
+ * @param obj: object to be serialized
143
+ * @param msg: the log message to write
144
+ * @param ...args: format string values when `msg` is a format string
145
+ */
146
+ error : pino . LogFn ;
147
+ /**
148
+ * Log at `'warn'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
149
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
150
+ *
151
+ * @typeParam T: the interface of the object being serialized. Default is object.
152
+ * @param obj: object to be serialized
153
+ * @param msg: the log message to write
154
+ * @param ...args: format string values when `msg` is a format string
155
+ */
156
+ warn : pino . LogFn ;
157
+ /**
158
+ * Log at `'info'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
159
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
160
+ *
161
+ * @typeParam T: the interface of the object being serialized. Default is object.
162
+ * @param obj: object to be serialized
163
+ * @param msg: the log message to write
164
+ * @param ...args: format string values when `msg` is a format string
165
+ */
166
+ info : pino . LogFn ;
167
+ /**
168
+ * Log at `'debug'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
169
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
170
+ *
171
+ * @typeParam T: the interface of the object being serialized. Default is object.
172
+ * @param obj: object to be serialized
173
+ * @param msg: the log message to write
174
+ * @param ...args: format string values when `msg` is a format string
175
+ */
176
+ debug : pino . LogFn ;
177
+ /**
178
+ * Log at `'trace'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
179
+ * If more args follows `msg`, these will be used to format `msg` using `util.format`.
180
+ *
181
+ * @typeParam T: the interface of the object being serialized. Default is object.
182
+ * @param obj: object to be serialized
183
+ * @param msg: the log message to write
184
+ * @param ...args: format string values when `msg` is a format string
185
+ */
186
+ trace : pino . LogFn ;
187
+ /**
188
+ * Noop function.
189
+ */
190
+ silent : pino . LogFn ;
191
+ }
192
+
195
193
type Bindings = Record < string , any > ;
196
194
197
195
type Level = "fatal" | "error" | "warn" | "info" | "debug" | "trace" ;
198
196
type LevelWithSilent = pino . Level | "silent" ;
197
+
198
+ type SerializerFn = ( value : any ) => any ;
199
+ type WriteFn = ( o : object ) => void ;
199
200
200
201
type LevelChangeEventListener = (
201
202
lvl : LevelWithSilent | string ,
@@ -278,6 +279,8 @@ declare namespace pino {
278
279
( msg : string , ...args : any [ ] ) : void ;
279
280
}
280
281
282
+ interface PrettyOptions extends PinoPrettyOptions { }
283
+
281
284
interface LoggerOptions {
282
285
transport ?: TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions
283
286
/**
@@ -756,10 +759,13 @@ export type LevelChangeEventListener = pino.LevelChangeEventListener;
756
759
export type LogDescriptor = pino . LogDescriptor ;
757
760
export type Logger = pino . Logger ;
758
761
export type SerializedError = pino . SerializedError ;
762
+ export type SerializerFn = pino . SerializerFn ;
759
763
export type SerializedRequest = pino . SerializedRequest ;
760
764
export type SerializedResponse = pino . SerializedResponse ;
765
+ export type WriteFn = pino . WriteFn ;
761
766
762
767
// Interfaces
768
+ export interface BaseLogger extends pino . BaseLogger { }
763
769
export interface ChildLoggerOptions extends pino . ChildLoggerOptions { }
764
770
export interface DestinationStream extends pino . DestinationStream { }
765
771
export interface LevelMapping extends pino . LevelMapping { }
@@ -768,6 +774,7 @@ export interface LogFn extends pino.LogFn {}
768
774
export interface LoggerOptions extends pino . LoggerOptions { }
769
775
export interface MultiStreamOptions extends pino . MultiStreamOptions { }
770
776
export interface MultiStreamRes extends pino . MultiStreamRes { }
777
+ export interface PrettyOptions extends pino . PrettyOptions { }
771
778
export interface StreamEntry extends pino . StreamEntry { }
772
779
export interface TransportBaseOptions extends pino . TransportBaseOptions { }
773
780
export interface TransportMultiOptions extends pino . TransportMultiOptions { }
0 commit comments