Skip to content

Commit

Permalink
add types and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
theoephraim committed Dec 11, 2024
1 parent 2ffe59c commit b5c447e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
17 changes: 17 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,23 @@ const hooks = {
}
```


<a id="streamWrite"></a>
##### `streamWrite`

Allows for manipulating the _stringified_ JSON log data just before writing to various transports.

The method receives the stringified JSON and must return valid stringified JSON.

For example:
```js
const hooks = {
streamWrite (s) {
return s.replaceAll('sensitive-api-key', 'XXX')
}
}
```

<a id=opt-formatters></a>
#### `formatters` (Object)

Expand Down
6 changes: 6 additions & 0 deletions pino.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,12 @@ declare namespace pino {
* using apply, like so: method.apply(this, newArgumentsArray).
*/
logMethod?: (this: Logger, args: Parameters<LogFn>, method: LogFn, level: number) => void;

/**
* Allows for manipulating the stringified JSON log output just before writing to various transports.
* This function must return a string and must be valid JSON.
*/
streamWrite?: (s: string) => string;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion pino.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ const defaultOptions = {
}
}),
hooks: {
logMethod: undefined
logMethod: undefined,
streamWrite: undefined
},
timestamp: epochTime,
name: undefined,
Expand Down

0 comments on commit b5c447e

Please sign in to comment.