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

Add ability to format time and level with user-defined prettifiers #263

Merged
merged 12 commits into from
Nov 16, 2021

Conversation

pearofducks
Copy link
Contributor

This would close issues like #185, and put more formatting capabilities into userland.

If another option-key besides customPrettifiers should be used I'm happy to switch. I think the docs are a bit open to interpretation even though I see this option is only being used to prettify object-formatting right now.

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.

Could you document this option?

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1458816767

  • 0 of 6 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 1420403642: 0.0%
Covered Lines: 320
Relevant Lines: 320

💛 - Coveralls

@coveralls
Copy link

coveralls commented Nov 14, 2021

Pull Request Test Coverage Report for Build 1467093039

  • 7 of 7 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-100.0%) to 0.0%

Totals Coverage Status
Change from base Build 1420403642: -100.0%
Covered Lines: 0
Relevant Lines: 0

💛 - Coveralls

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
pearofducks and others added 5 commits November 14, 2021 21:04
Co-authored-by: James Sumners <james@sumners.email>
Co-authored-by: James Sumners <james@sumners.email>
Co-authored-by: James Sumners <james@sumners.email>
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

Readme.md Outdated

Note that prettifiers do not include any coloring, if the stock coloring on `level` is desired, it can be accomplished using the following:
```js
const levelColorize = require('pino-pretty/lib/colors.js')(true)
Copy link
Member

Choose a reason for hiding this comment

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

I do not want to promote relying on an internal API like this. If we are going to support this, we should expose the colorizer as a property of the main export, e.g. const { colorizerFactory } = require('pino-pretty').

Copy link
Member

Choose a reason for hiding this comment

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

Good spot, I missed it!

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.

Remove the usage of pino-pretty/lib/colors.js and expose it.

@pearofducks
Copy link
Contributor Author

No problem!

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Last nit, and then everything looks good to me.

pearofducks and others added 2 commits November 16, 2021 08:36
Co-authored-by: James Sumners <james@sumners.email>
Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you for working with the review process.

@@ -214,4 +214,5 @@ function build (opts = {}) {

module.exports = build
module.exports.prettyFactory = prettyFactory
module.exports.colorizerFactory = colors
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test to cover this new public API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure - I've expanded the colorizer test to ensure both exports behave the same! If there's something else you had in mind please let me know. 👍

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

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

4 participants