pinojs / pino-pretty

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

Add support for messageFormat strings containing conditionals #442

Closed timlohse1104 closed 1 year ago

timlohse1104 commented 1 year ago

See #441

It's now possible to pass --messageFormat option containing conditional statements for log data.

Example log data: {level: 30, req: {id: 'foo'}}

Example --messageFormat containing conditional: "{level} - {if req.id}({req.id}){end}{if msg} - {msg}{end}"

Example output: "30 - (foo)"

Unescaped if / end block within --messageFormat will just be deleted.

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 5649830685


Totals Coverage Status
Change from base Build 5620622122: 0.0%
Covered Lines: 419
Relevant Lines: 419

💛 - Coveralls
timlohse1104 commented 1 year ago

Updated documentation with --messageFormat condition example. Add matching for condition and property keys. Add further unit tests for parseMessageFormat function.

timlohse1104 commented 1 year ago

Hey @jsumners thanks for the code review. I will look into it after work. Please excuse my poor english var and function wording. Will edit.

jsumners commented 1 year ago

Hey @jsumners thanks for the code review. I will look into it after work. Please excuse my poor english var and function wording. Will edit.

No problem. The review phase is there to get us into an agreeable state.