Skip to content

Commit

Permalink
docs(help): use formatters since useLevelLabels is deprecated (#1533)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkerone committed Aug 27, 2022
1 parent c31bb1b commit 548f257
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions docs/help.md
Expand Up @@ -154,9 +154,29 @@ for information on this is handled.
<a id="level-string"></a>
## Log levels as labels instead of numbers
Pino log lines are meant to be parseable. Thus, Pino's default mode of operation
is to print the level value instead of the string name. However, while it is
possible to set the `useLevelLabels` option, we recommend using one of these
options instead if you are able:
is to print the level value instead of the string name.
However, you can use the [`formatters`](/docs/api.md#formatters-object) option
with a [`level`](/docs/api.md#level) function to print the string name instead the level value :

```js
const pino = require('pino')

const log = pino({
formatters: {
level: (label) => {
return {
level: label
}
}
}
})

log.info('message')

// {"level":"info","time":1661632832200,"pid":18188,"hostname":"foo","msg":"message"}
```

Although it is works, we recommend using one of these options instead if you are able:

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

0 comments on commit 548f257

Please sign in to comment.