Skip to content

Commit

Permalink
fix incorrect type definition of censor function (#1389)
Browse files Browse the repository at this point in the history
* fix incorrect type definition of censor function

`censor` takes two arguments: value and path

* add assertions for censor function

censor function should take two arguments: value and path
  • Loading branch information
mksmtn authored Apr 8, 2022
1 parent 75f0dc7 commit 47e97f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pino.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type CustomLevelLogger<Options> = Options extends { customLevels: Record<string,

interface redactOptions {
paths: string[];
censor?: string | ((v: any) => any);
censor?: string | ((value: any, path: string[]) => any);
remove?: boolean;
}

Expand Down
8 changes: 8 additions & 0 deletions test/types/pino.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ pino({
redact: { paths: [], censor: () => "SECRET" },
});

pino({
redact: { paths: [], censor: (value) => value },
});

pino({
redact: { paths: [], censor: (value, path) => path.join() },
});

pino({
depthLimit: 1
});
Expand Down

0 comments on commit 47e97f7

Please sign in to comment.