forked from Cylo-Traders/Agrocylo-PIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.module.ts
More file actions
36 lines (34 loc) · 1.06 KB
/
Copy pathlogger.module.ts
File metadata and controls
36 lines (34 loc) · 1.06 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
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { LoggerModule as PinoLoggerModule } from 'nestjs-pino';
/**
* Structured logging built on Pino. In development logs are pretty-printed for
* readability; in production they are emitted as JSON for log aggregation.
*/
@Module({
imports: [
PinoLoggerModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (config: ConfigService) => {
const isProduction = config.get<string>('app.nodeEnv') === 'production';
return {
pinoHttp: {
level: config.get<string>('app.logLevel') ?? 'info',
transport: isProduction
? undefined
: {
target: 'pino-pretty',
options: {
singleLine: true,
translateTime: 'SYS:standard',
ignore: 'pid,hostname',
},
},
},
};
},
}),
],
})
export class LoggerModule {}