-
Notifications
You must be signed in to change notification settings - Fork 152
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: Add context to level customPrettifier #493
Conversation
Include both the "final" log label as well as the colorized output, if applicable, to `level` prettifier function to give users more control over level output.
The only thing missing is that the Typescript typings for all customPrettifiers use |
Modified typings...it should work now |
Related to #494 -- providing colors to all customPrettifier funcs would add another argument to this function signature which I'm not super jazzed about. If I can get feedback on #494 and this cohesively -- or if ya'll would prefer I close both of these and open a new PR with everything combined -- let me know. But I'm thinking: Change signature for customPrettifier to be 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 |
Same implementation as pinojs#493 but using object for extras argument for compatibility with future signature expansion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@jsumners could you take a look? |
Which part @mcollina ? This PR or the changes I mentioned above in |
@FoxxMD sorry I don't understand the question. |
Please...read my comment above and respond to it. #493 (comment) For these changes and #494, after I opened these PRs, I found the signatures to be unwiedly
I built out another branch, Take a look at the Per my comment above, the question:
"lgtm" reads as if you didn't see this. |
I missed that. Please send one PR thanks. |
…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
Currently the customPrettifier for
level
only returns the numeric level value (iflevelKey
is not used) which means that anyone who wants to modify value returned has to re-implement the levels pino-pretty already has access to as well as calculate the label to use, which pino-pretty also already does.This PR include both the "final" log label as well as the colorized output, if applicable, to
level
prettifier function to give users more control over level output.It has the additional benefit of enabling users to handle their own level alignment (#489 #140) since they have access to the final string values for level. As example implementation for aligning with spaces: