Skip to content

Commit 548f257

Browse files
authoredAug 27, 2022
docs(help): use formatters since useLevelLabels is deprecated (#1533)
1 parent c31bb1b commit 548f257

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed
 

‎docs/help.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,29 @@ for information on this is handled.
154154
<a id="level-string"></a>
155155
## Log levels as labels instead of numbers
156156
Pino log lines are meant to be parseable. Thus, Pino's default mode of operation
157-
is to print the level value instead of the string name. However, while it is
158-
possible to set the `useLevelLabels` option, we recommend using one of these
159-
options instead if you are able:
157+
is to print the level value instead of the string name.
158+
However, you can use the [`formatters`](/docs/api.md#formatters-object) option
159+
with a [`level`](/docs/api.md#level) function to print the string name instead the level value :
160+
161+
```js
162+
const pino = require('pino')
163+
164+
const log = pino({
165+
formatters: {
166+
level: (label) => {
167+
return {
168+
level: label
169+
}
170+
}
171+
}
172+
})
173+
174+
log.info('message')
175+
176+
// {"level":"info","time":1661632832200,"pid":18188,"hostname":"foo","msg":"message"}
177+
```
178+
179+
Although it is works, we recommend using one of these options instead if you are able:
160180

161181
1. If the only change desired is the name then a transport can be used. One such
162182
transport is [`pino-text-level-transport`](https://npm.im/pino-text-level-transport).

0 commit comments

Comments
 (0)
Please sign in to comment.