@rtorcato/api-logger
v1.1.0
Published
Framework-agnostic pino logger factory for Node API projects.
Maintainers
Readme
@rtorcato/api-logger
Framework-agnostic pino logger factory for Node API projects.
import { createLogger } from '@rtorcato/api-logger'
const log = createLogger() // pretty in dev, JSON in production
log.info({ userId: 1 }, 'request handled')API
createLogger(options?, destination?)
Returns a configured pino Logger.
options— standard pinoLoggerOptionspluspretty?: boolean.prettydefaults totruewhenNODE_ENV !== 'production'and routes throughpino-pretty(install it as an optional peer dependency to use it).prettyOptions?— forwarded topino-prettywhenprettyis on, e.g.{ colorize: true, singleLine: true, translateTime: 'HH:MM:ss', ignore: 'pid,hostname' }. Ignored whenprettyisfalseor adestinationis supplied.leveldefaults to theLOG_LEVELenv var, theninfo.destination— an optional pino destination stream. When supplied it takes precedence over the pretty transport.
License
MIT
