-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
logger.d.ts
71 lines (61 loc) · 2.54 KB
/
logger.d.ts
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
65
66
67
68
69
70
71
import { FastifyError } from '@fastify/error'
import { RouteGenericInterface } from './route'
import { FastifyRequest } from './request'
import { FastifyReply } from './reply'
import { RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, ContextConfigDefault } from './utils'
import { FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider'
import { FastifySchema } from './schema'
import pino from 'pino'
/**
* Standard Fastify logging function
*/
export type FastifyLogFn = pino.LogFn
export type LogLevel = pino.LevelWithSilent
export type Bindings = pino.Bindings
export type ChildLoggerOptions = pino.ChildLoggerOptions
export type FastifyBaseLogger = pino.BaseLogger & {
child(bindings: Bindings, options?: ChildLoggerOptions): FastifyBaseLogger
}
// TODO delete FastifyBaseLogger in the next major release. It seems that it is enough to have only FastifyBaseLogger.
/**
* @deprecated Use FastifyBaseLogger instead
*/
export type FastifyLoggerInstance = FastifyBaseLogger
export interface FastifyLoggerStreamDestination {
write(msg: string): void;
}
export type PinoLoggerOptions = pino.LoggerOptions
/**
* Fastify Custom Logger options.
*/
export interface FastifyLoggerOptions<
RawServer extends RawServerBase = RawServerDefault,
RawRequest extends FastifyRequest<RouteGenericInterface, RawServer, RawRequestDefaultExpression<RawServer>, FastifySchema, FastifyTypeProvider> = FastifyRequest<RouteGenericInterface, RawServer, RawRequestDefaultExpression<RawServer>, FastifySchema, FastifyTypeProviderDefault>,
RawReply extends FastifyReply<RawServer, RawRequestDefaultExpression<RawServer>, RawReplyDefaultExpression<RawServer>, RouteGenericInterface, ContextConfigDefault, FastifySchema, FastifyTypeProvider> = FastifyReply<RawServer, RawRequestDefaultExpression<RawServer>, RawReplyDefaultExpression<RawServer>, RouteGenericInterface, ContextConfigDefault, FastifySchema, FastifyTypeProviderDefault>,
> {
serializers?: {
req?: (req: RawRequest) => {
method?: string;
url?: string;
version?: string;
hostname?: string;
remoteAddress?: string;
remotePort?: number;
[key: string]: unknown;
};
err?: (err: FastifyError) => {
type: string;
message: string;
stack: string;
[key: string]: unknown;
};
res?: (res: RawReply) => {
statusCode: string | number;
[key: string]: unknown;
};
};
level?: string;
file?: string;
genReqId?: (req: RawRequest) => string;
stream?: FastifyLoggerStreamDestination;
}