Closed FoxxMD closed 8 months ago
The only thing missing is that the Typescript typings for all customPrettifiers use Record<string, (inputData: string | object) => string>
so TS reports errors when the end user uses level: (out, label, colorized) => { ...
and im not sure how to address this.
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 (value: string | object, extras: object)
so that all these additional variables can be destructured from the second arg to avoid requiring the user to know argument order for multiple signatures.
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
@jsumners could you take a look?
Which part @mcollina ? This PR or the changes I mentioned above in additionalFunctionality
branch? https://github.com/pinojs/pino-pretty/pull/493#issuecomment-1964469268
@FoxxMD sorry I don't understand the question.
Please...read my comment above and respond to it. https://github.com/pinojs/pino-pretty/pull/493#issuecomment-1964469268
For these changes and #494, after I opened these PRs, I found the signatures to be unwiedly
providing colors to all customPrettifier funcs would add another argument
I built out another branch, additionalFunctionality
that includes functionally the same changes as this and #494 but with a more normalized signature for both to address this.
Take a look at the customPrettier
section on the readme in the additionalFunctionality
branch or the diff to see what changes I made.
Per my comment above, the question:
Can I get feedback on #494 and this cohesively -- or would ya'll prefer I close both of these and open a new PR with everything combined (from the
additionalFuntionality
branch)
"lgtm" reads as if you didn't see this.
I missed that. Please send one PR thanks.
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: