pino-zen
v3.2.1
Published
Zen for Pino logging
Readme
pino-zen
Colored log formatter for Pino JSON logs. Works as a Pino transport or a CLI pipe.
Install
npm install pino-zen # project dependency
npm install -g pino-zen # global CLI
npx pino-zen # run without installingPino Transport
import pino from "pino"
const logger = pino({
transport: {
target: "pino-zen",
},
})Multiple Targets
const logger = pino({
level: "debug",
transport: {
targets: [
{ target: "pino/file", options: { destination: "app.log" } },
{ target: "pino-zen" },
],
},
})Custom Destination
By default the transport writes to stdout. Pass a file path or file descriptor via destination:
{ target: "pino-zen", options: { destination: "/var/log/app.log" } }CLI
Pipe any Pino NDJSON output through the CLI:
node app.js | pino-zen
node app.js | npx pino-zen| Flag | Short | Description |
|------|-------|-------------|
| --module <field> | -m | Use a field as the module prefix |
Options
These options work with both the transport and the CLI.
Module Mode
Prepends a color-coded, right-aligned module name to each log line. Useful for distinguishing logs from different components.
Transport:
const logger = pino({
transport: {
target: "pino-zen",
options: { module: "name" },
},
})
logger.info({ name: "api" }, "request processed")
logger.info({ name: "auth" }, "user verified")CLI:
node app.js | pino-zen -m nameOutput:
[api] INFO request processed
[auth] INFO user verifiedModule names are automatically color-cycled and right-aligned to the longest name seen.
Field Suppression
Hide specific fields from output with the formatter option:
{
target: "pino-zen",
options: { formatter: { pid: false, hostname: false } },
}License
MIT
