1 | import { FastifyError } from 'fastify-error'
|
2 | import { RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression } from './utils'
|
3 | import { FastifyRequest, RequestGenericInterface } from './request'
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export interface FastifyLogFn {
|
9 | (msg: string, ...args: unknown[]): void;
|
10 | (obj: object, msg?: string, ...args: unknown[]): void;
|
11 | }
|
12 |
|
13 | export type LogLevel = 'info' | 'error' | 'debug' | 'fatal' | 'warn' | 'trace'
|
14 |
|
15 | export type SerializerFn = (value: unknown) => unknown;
|
16 |
|
17 | export interface Bindings {
|
18 | level?: LogLevel | string;
|
19 | serializers?: { [key: string]: SerializerFn };
|
20 | [key: string]: unknown;
|
21 | }
|
22 |
|
23 | export interface FastifyLoggerInstance {
|
24 | info: FastifyLogFn;
|
25 | warn: FastifyLogFn;
|
26 | error: FastifyLogFn;
|
27 | fatal: FastifyLogFn;
|
28 | trace: FastifyLogFn;
|
29 | debug: FastifyLogFn;
|
30 | child(bindings: Bindings): FastifyLoggerInstance;
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | export interface FastifyLoggerOptions<
|
39 | RawServer extends RawServerBase = RawServerDefault,
|
40 | RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
41 | RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>
|
42 | > {
|
43 | serializers?: {
|
44 | req: (req: RawRequest) => {
|
45 | method: string;
|
46 | url: string;
|
47 | version: string;
|
48 | hostname: string;
|
49 | remoteAddress: string;
|
50 | remotePort: number;
|
51 | };
|
52 | err: (err: FastifyError) => {
|
53 | type: string;
|
54 | message: string;
|
55 | stack: string;
|
56 | [key: string]: any;
|
57 | };
|
58 | res: (res: RawReply) => {
|
59 | statusCode: string | number;
|
60 | };
|
61 | };
|
62 | level?: string;
|
63 | genReqId?: <RequestGeneric extends RequestGenericInterface = RequestGenericInterface>(req: FastifyRequest<RequestGeneric, RawServer, RawRequest>) => string;
|
64 | }
|