Skip to content

Commit

Permalink
Add customColors to typescript definition for PrettyOptions (#440)
Browse files Browse the repository at this point in the history
* Add customColors property to PrettyOptions type definition

* Add missing semicolon to pino-pretty type-tests

* Drop superflous options2 variable from pino-pretty type tests

* Add customLevels and customColors to pino-pretty type tests
  • Loading branch information
Hufschmidt authored Jul 19, 2023
1 parent e510233 commit d195503
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ interface PrettyOptions_ {
* @example ( Object ) customLevels: { info: 10, some_level: 40 }
*/
customLevels?: string|object;
/**
* Change the level colors to an user custom preset.
*
* Can be a CSV string in 'level_name:color_value' format or an object.
* Also supports 'default' as level_name for fallback color.
*
* @example ( CSV ) customColors: 'info:white,some_level:red'
* @example ( Object ) customColors: { info: 'white', some_level: 'red' }
*/
customColors?: string|object;
}

declare namespace PinoPretty {
Expand Down
33 changes: 4 additions & 29 deletions test/types/pino-pretty.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,8 @@ const options: PinoPretty.PrettyOptions = {
return value.toString().toUpperCase();
}
},
sync: false,
destination: 2,
append: true,
mkdir: true,
};

const options2: PrettyOptions = {
colorize: true,
crlf: false,
errorLikeObjectKeys: ["err", "error"],
errorProps: "",
hideObject: true,
levelKey: "level",
levelLabel: "foo",
messageFormat: false,
ignore: "",
levelFirst: false,
messageKey: "msg",
timestampKey: "timestamp",
minimumLevel: "trace",
translateTime: "UTC:h:MM:ss TT Z",
singleLine: false,
customPrettifiers: {
key: (value) => {
return value.toString().toUpperCase();
}
},
customLevels: 'verbose:5',
customColors: 'default:white,verbose:gray',
sync: false,
destination: 2,
append: true,
Expand All @@ -76,5 +51,5 @@ expectType<PrettyStream>(PinoPrettyStar.default(options));
expectType<PrettyStream>(PinoPrettyCjsImport.PinoPretty(options));
expectType<PrettyStream>(PinoPrettyCjsImport.default(options));
expectType<any>(PinoPrettyCjs(options));
expectType<PinoPretty.ColorizerFactory>(colorizerFactory)
expectType<PinoPretty.PrettyFactory>(prettyFactory)
expectType<PinoPretty.ColorizerFactory>(colorizerFactory);
expectType<PinoPretty.PrettyFactory>(prettyFactory);

0 comments on commit d195503

Please sign in to comment.