-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlogger.config.ts
36 lines (34 loc) · 1.04 KB
/
logger.config.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
import type { RawRequestDefaultExpression, RawServerBase } from 'fastify';
import type { Params } from 'nestjs-pino';
import { randomUUID } from 'node:crypto';
import { multistream } from 'pino';
const passUrl = new Set(['/health']);
export const genReqId = (req: RawRequestDefaultExpression<RawServerBase>) => <string>req.headers['X-Request-Id'] || randomUUID();
export const loggerOptions = <Params>{
pinoHttp: [
{
quietReqLogger: true,
...(process.env.NODE_ENV === 'production'
? {}
: {
level: 'debug',
transport: {
target: 'pino-pretty',
options: { sync: true, singleLine: true },
},
}),
autoLogging: {
ignore: (req) => passUrl.has(req.originalUrl),
},
customProps: (req) => req.customProps,
},
multistream(
[
{ level: 'debug', stream: process.stdout },
{ level: 'error', stream: process.stderr },
{ level: 'fatal', stream: process.stderr },
],
{ dedupe: true },
),
],
};