pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.22k stars 147 forks source link

feat: Provide colorette object to messageFormat #494

Closed FoxxMD closed 6 months ago

FoxxMD commented 6 months ago

Enables users to use available colors based on colorize context of the pino-pretty instance.

Currently if a user wants to color their messages they need to create their own instances of Colorette and implement logic, outside of pino-pretty, to make sure the useColors option passed matches what was given to pino-pretty as colorize. However pino-pretty already has this object available...this PR extends messageFormat to add the existing Colorette instance as a fourth parameter so that the user doesn't need to do that extra work.

FoxxMD commented 6 months ago

Question though...would it be acceptable to extend this functionality to customPrettifiers so that colors can be accessed from essentially all functions for customizing output?

EDIT: A combined branch example of providing colors to all prettifiers -- see usage under customPrettifiers section in readme https://github.com/FoxxMD/pino-pretty/tree/additionalFunctionality?tab=readme-ov-file#options