pinojs/pino-pretty

Format pino log as same as NestJS log

androidotai opened this issue · 1 comments

How to put context in '[ ]' and put it after log level, same as NesJS log format?

NestJS Default Log

[Nest] 6932  - 07/13/2023, 6:11:18 PM     LOG [NestFactory] Starting Nest application...
[Nest] 6932  - 07/13/2023, 6:11:18 PM     LOG [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 6932  - 07/13/2023, 6:11:18 PM     LOG [RoutesResolver] AppController {/}: +67ms
[Nest] 6932  - 07/13/2023, 6:11:18 PM     LOG [RouterExplorer] Mapped {/, GET} route +3ms
[Nest] 6932  - 07/13/2023, 6:11:18 PM     LOG [NestApplication] Nest application successfully started +3ms

pino Log with pino-prettier

[2023-07-13 18:04:54.145:54+0800] INFO (18924 on A-to-Z): Starting Nest application... {"context":"NestFactory"}
[2023-07-13 18:04:54.153:54+0800] INFO (18924 on A-to-Z): AppModule dependencies initialized {"context":"InstanceLoader"}
[2023-07-13 18:04:54.154:54+0800] INFO (18924 on A-to-Z): LoggerModule dependencies initialized {"context":"InstanceLoader"}
[2023-07-13 18:04:54.189:54+0800] INFO (18924 on A-to-Z): AppController {/}: {"context":"RoutesResolver"}
[2023-07-13 18:04:54.191:54+0800] INFO (18924 on A-to-Z): Mapped {/, GET} route {"context":"RouterExplorer"}
[2023-07-13 18:04:54.192:54+0800] INFO (18924 on A-to-Z): Mapped {/error, GET} route {"context":"RouterExplorer"}
[2023-07-13 18:04:54.195:54+0800] INFO (18924 on A-to-Z): Nest application successfully started {"context":"NestApplication"}`

You can use messageFormat option to configure your own format