1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | import { IncomingMessage, ServerResponse } from 'http';
|
11 | import { DestinationStream, Level, Logger, LoggerOptions } from 'pino';
|
12 |
|
13 | export = PinoHttp;
|
14 |
|
15 | declare function PinoHttp(opts?: PinoHttp.Options, stream?: DestinationStream): PinoHttp.HttpLogger;
|
16 | declare function PinoHttp(stream?: DestinationStream): PinoHttp.HttpLogger;
|
17 |
|
18 | declare namespace PinoHttp {
|
19 | interface HttpLogger {
|
20 | (req: IncomingMessage, res: ServerResponse, next?: () => void): void;
|
21 | logger: Logger;
|
22 | }
|
23 | type ReqId = number | string | object;
|
24 |
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 | interface Options extends LoggerOptions {
|
31 | logger?: Logger | undefined;
|
32 | genReqId?: GenReqId | undefined;
|
33 | useLevel?: Level | undefined;
|
34 | stream?: DestinationStream | undefined;
|
35 | autoLogging?: boolean | AutoLoggingOptions | undefined;
|
36 | customLogLevel?: ((res: ServerResponse, error: Error) => Level) | undefined;
|
37 | customSuccessMessage?: ((res: ServerResponse) => string) | undefined;
|
38 | customErrorMessage?: ((error: Error, res: ServerResponse) => string) | undefined;
|
39 | customAttributeKeys?: CustomAttributeKeys | undefined;
|
40 | wrapSerializers?: boolean | undefined;
|
41 | reqCustomProps?: ((req: IncomingMessage, res: ServerResponse) => object) | undefined;
|
42 | quietReqLogger?: boolean | undefined;
|
43 | }
|
44 |
|
45 | interface GenReqId {
|
46 | (req: IncomingMessage): ReqId;
|
47 | }
|
48 |
|
49 | interface AutoLoggingOptions {
|
50 | ignore?: ((req: IncomingMessage) => boolean);
|
51 | ignorePaths?: Array<string | RegExp> | undefined;
|
52 | getPath?: ((req: IncomingMessage) => string | undefined) | undefined;
|
53 | }
|
54 |
|
55 | interface CustomAttributeKeys {
|
56 | req?: string | undefined;
|
57 | res?: string | undefined;
|
58 | err?: string | undefined;
|
59 | reqId?: string | undefined;
|
60 | responseTime?: string | undefined;
|
61 | }
|
62 |
|
63 | const startTime: unique symbol;
|
64 | }
|
65 |
|
66 | declare module 'http' {
|
67 | interface IncomingMessage {
|
68 | id: PinoHttp.ReqId;
|
69 | log: Logger;
|
70 | }
|
71 |
|
72 | interface ServerResponse {
|
73 | err?: Error | undefined;
|
74 | }
|
75 |
|
76 | interface OutgoingMessage {
|
77 | [PinoHttp.startTime]: number;
|
78 | }
|
79 | }
|
80 |
|
\ | No newline at end of file |