forked from fastify/fastify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.d.ts
More file actions
64 lines (58 loc) · 2 KB
/
logger.d.ts
File metadata and controls
64 lines (58 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { FastifyError } from 'fastify-error'
import { RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression } from './utils'
import { FastifyRequest, RequestGenericInterface } from './request'
/**
* Standard Fastify logging function
*/
export interface FastifyLogFn {
(msg: string, ...args: unknown[]): void;
(obj: object, msg?: string, ...args: unknown[]): void;
}
export type LogLevel = 'info' | 'error' | 'debug' | 'fatal' | 'warn' | 'trace'
export type SerializerFn = (value: unknown) => unknown;
export interface Bindings {
level?: LogLevel | string;
serializers?: { [key: string]: SerializerFn };
[key: string]: unknown;
}
export interface FastifyLoggerInstance {
info: FastifyLogFn;
warn: FastifyLogFn;
error: FastifyLogFn;
fatal: FastifyLogFn;
trace: FastifyLogFn;
debug: FastifyLogFn;
child(bindings: Bindings): FastifyLoggerInstance;
}
/**
* Fastify Custom Logger options. To enable configuration of all Pino options,
* refer to this example:
* https://github.com/fastify/fastify/blob/2f56e10a24ecb70c2c7950bfffd60eda8f7782a6/docs/TypeScript.md#example-5-specifying-logger-types
*/
export interface FastifyLoggerOptions<
RawServer extends RawServerBase = RawServerDefault,
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>
> {
serializers?: {
req: (req: RawRequest) => {
method: string;
url: string;
version: string;
hostname: string;
remoteAddress: string;
remotePort: number;
};
err: (err: FastifyError) => {
type: string;
message: string;
stack: string;
[key: string]: any;
};
res: (res: RawReply) => {
statusCode: string | number;
};
};
level?: string;
genReqId?: <RequestGeneric extends RequestGenericInterface = RequestGenericInterface>(req: FastifyRequest<RequestGeneric, RawServer, RawRequest>) => string;
}