Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Provide colorette object to messageFormat #494

Closed
wants to merge 1 commit into from

Conversation

FoxxMD
Copy link
Contributor

@FoxxMD FoxxMD commented Feb 23, 2024

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.

Enables users to use available colors based on `colorize` context of the pino-pretty instance
@FoxxMD
Copy link
Contributor Author

FoxxMD commented Feb 23, 2024

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

FoxxMD added a commit to FoxxMD/pino-pretty that referenced this pull request Feb 26, 2024
Enables users to use available colors based on `colorize` context of the pino-pretty instance

Variant of pinojs#494 that provides colors as extras object for compatibility with future customPrettifier extras argument
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@FoxxMD FoxxMD closed this Feb 29, 2024
mcollina pushed a commit that referenced this pull request Mar 20, 2024
…rmat (#495)

* feat: Add label and colorized output for level customPrettifier func

Same implementation as #493 but using object for extras argument for compatibility with future signature expansion

* feat: Provide colorette object to message format function

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

Variant of #494 that provides colors as extras object for compatibility with future customPrettifier extras argument

* feat: Provide colorette object to prettifyObject

All keys for customPrettifier, other than logs, now provide colors as property on an additional `extras` object for the prettifyObject function signature

* feat: Add colors to level prettifier function signature

* Modify level prettifier function signature to match other prettifiers
  * Since only the first argument was documented anyway this shouldn't be a breaking change.

* docs: Update docs to showcase colors and standard customPrettifiers function signature

* fix: Missing colors on colorizer when custom level colors are provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants