pino-charm
v0.7.0
Published
Minimal pino formatter
Maintainers
Readme
pino-charm
Minimal pino formatter.

About
pino-charm is a small pino transport for readable terminal logs. It keeps the output compact, adds colored levels and makes errors easier to scan.
Installation
# pnpm
pnpm add pino-charm -D
# yarn
yarn add pino-charm -D
# npm
npm install pino-charm -DUsage
import pino from 'pino'
const logger = pino({
transport: {
target: 'pino-charm'
}
})
logger.debug('Starting server...')
logger.info({ port: 3000 }, 'Server started')
logger.warn({ duration: 1200, path: '/users' }, 'Slow request')
logger.error(new Error('Database connection failed'))Best practices
A few small things that make logs nicer to read:
Error causes
Use pino's errWithCause serializer to show the cause field for errors.
import pino from 'pino'
const logger = pino({
serializers: {
err: pino.stdSerializers.errWithCause
},
transport: {
target: 'pino-charm'
}
})Nested context
Use nestedKey to keep application fields separate from pino's own fields. This helps avoid collisions with keys like time, level, msg or err, while keeping the formatted output clean.
import pino from 'pino'
const logger = pino({
nestedKey: 'context',
transport: {
target: 'pino-charm',
options: {
nestedKey: 'context'
}
}
})
logger.info({ port: 3000, time: true }, 'Server started')Inspiration
Inspired by these lovely packages:
License
MIT
