Closed FoxxMD closed 8 months ago
Please hold off...there's a bug somewhere that is showing up in my app but not in tests.
Fixed :+1:
@jsumners I think it's safer to bump a major on this one.
@mcollina thank you for the effort on getting pino-roll updated! Any chance this can move forward too? :)
Thank you! :heart:
This PR is combined changes from #493 and #494 (see these comments 1 2). Summary of changes:
Extend/Normalize all "format" functions with
extras
objectAll "format" functions --
customPrettifiers
,level
, andmessageFormat
-- now have an additional parameter,extras
that is an object ofRecord<string, any>
. This allows for additional data and future (optional) functionality to be provided to these functions without having to change function signature again.This change is backward compatible but the examples in the documentation for these functions has been updated to include the existing, full, list of parameters that were available instead of just the first parameter. EX
Previous:
New:
Provide Colorette
colors
to all "format" functions #494Enables 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 ascolorize
. However pino-pretty already has this object available...this PR providescolors
to theextras
object for all format functions so that the user doesn't need to do that extra work.Add context to
level
customPrettifier #493Currently 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. These values are included in theextras
object: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: