pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

New option to hide level and timestamp at the beginning of a line #444

Closed timlohse1104 closed 1 year ago

timlohse1104 commented 1 year ago

In my testing with --messageFormat option i came across the question if it would be possible to mirror standard NestJS logs like this:

[Nest] 45816 - 23.07.2023, 22:09:14 LOG [NestFactory] Starting Nest application... +59ms

I tried to rebuild it with '--messageFormat' string / function but could not remove the timestampand levelin the beginning of every log.

I probably overlooked something. But if thats not the case i would like to add another option 'hideMetadata' (name to be discussed).

I would add logic into https://github.com/pinojs/pino-pretty/blob/master/index.js line 135 and following.

What do you think?

Would also contribute to this closed issue: https://github.com/pinojs/pino-pretty/issues/437

timlohse1104 commented 1 year ago

Please consider https://github.com/pinojs/pino-pretty/pull/445 .

vladshcherbin commented 1 year ago

try

{
  include: ''
}

or

{
  ignore: 'level,time'
}
timlohse1104 commented 1 year ago

Thanks @vladshcherbin that's avalid option. No need for a further parameter. This issue can be closed.

timlohse1104 commented 1 year ago

For anyone interested in a config to recreate NestJS logs see the below .pino-pretty.rc.

{ "ignore": "pid,hostname,level,time", "translateTime": false, "singleLine": false, "colorize": true, "hideObject": true, "messageFormat": "[Nest] {pid} - {if req.id} ({req.id}) - {end}{time} {level} {if context}[{context}] {end} {msg}" }

The only thing missing seems to be the log of timings and multiple colors in a log. Don't know if this is possible in current state of pino-pretty.