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

Update colorette to enable behaviour consistent with earlier pino-pretty versions #230

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ with keys corresponding to the options described in [CLI Arguments](#cliargs):

```js
{
colorize: colorette.options.enabled, // --colorize
colorize: colorette.isColorSupported, // --colorize
crlf: false, // --crlf
errorLikeObjectKeys: ['err', 'error'], // --errorLikeObjectKeys
errorProps: '', // --errorProps
Expand All @@ -150,7 +150,7 @@ with keys corresponding to the options described in [CLI Arguments](#cliargs):
```

The `colorize` default follows
[`colorette.options.enabled`](https://github.com/jorgebucaran/colorette#optionsenabled).
[`colorette.isColorSupported`](https://github.com/jorgebucaran/colorette#iscolorsupported).

`customPrettifiers` option provides the ability to add a custom prettify function
for specific log properties. `customPrettifiers` is an object, where keys are
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { options: coloretteOptions } = require('colorette')
const { isColorSupported } = require('colorette')
const pump = require('pump')
const { Transform } = require('readable-stream')
const abstractTransport = require('pino-abstract-transport')
Expand Down Expand Up @@ -29,7 +29,7 @@ const jsonParser = input => {
}

const defaultOptions = {
colorize: coloretteOptions.enabled,
colorize: isColorSupported,
crlf: false,
errorLikeObjectKeys: ERROR_LIKE_KEYS,
errorProps: '',
Expand Down
22 changes: 12 additions & 10 deletions lib/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ const plain = {
greyMessage: nocolor
}

const colorette = require('colorette')
const { createColors } = require('colorette')
const { white, bgRed, red, yellow, green, blue, gray, cyan } = createColors({ useColor: true })

const colored = {
default: colorette.white,
60: colorette.bgRed,
50: colorette.red,
40: colorette.yellow,
30: colorette.green,
20: colorette.blue,
10: colorette.gray,
message: colorette.cyan,
greyMessage: colorette.gray
default: white,
60: bgRed,
50: red,
40: yellow,
30: green,
20: blue,
10: gray,
message: cyan,
greyMessage: gray
}

function colorizeLevel (level, colorizer) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"dependencies": {
"args": "^5.0.1",
"colorette": "^1.3.0",
"colorette": "^2.0.0",
"dateformat": "^4.5.1",
"fast-safe-stringify": "^2.0.7",
"joycon": "^3.0.0",
Expand All @@ -46,15 +46,15 @@
"strip-json-comments": "^3.1.1"
},
"devDependencies": {
"@types/node": "^16.0.0",
"pino": "^6.0.0",
"@types/node": "^16.9.2",
"pino": "^6.13.2",
"pre-commit": "^1.2.2",
"rimraf": "^3.0.2",
"snazzy": "^9.0.0",
"standard": "^16.0.3",
"tap": "^15.0.0",
"tap": "^15.0.9",
"tsd": "^0.17.0",
"typescript": "^4.2.4"
"typescript": "^4.4.3"
},
"tsd": {
"directory": "./test/types"
Expand Down