Skip to content

Bunyan Transport Browser Server ​

NPM Version

Bunyan is a JSON logging library for Node.js services.

Transport Source

Installation ​

Install the required packages:

sh
npm i loglayer @loglayer/transport-bunyan bunyan
sh
pnpm add loglayer @loglayer/transport-bunyan bunyan
sh
yarn add loglayer @loglayer/transport-bunyan bunyan

Setup ​

typescript
import bunyan from 'bunyan'
import { LogLayer } from 'loglayer'
import { BunyanTransport } from "@loglayer/transport-bunyan"

const b = bunyan.createLogger({
  name: "my-logger",
  level: "trace",  // Show all log levels
  serializers: { 
    err: bunyan.stdSerializers.err  // Use Bunyan's error serializer
  }
})

const log = new LogLayer({
  errorFieldName: "err",  // Match Bunyan's error field name
  transport: new BunyanTransport({
    logger: b
  })
})

Configuration Options ​

Required Parameters ​

None - all parameters are optional.

Optional Parameters ​

NameTypeDefaultDescription
level"trace" | "debug" | "info" | "warn" | "error" | "fatal""trace"Minimum log level to process. Messages with a lower priority level will be ignored
enabledbooleantrueIf false, the transport will not send any logs to the logger
consoleDebugbooleanfalseIf true, the transport will also log messages to the console for debugging
idstring-A unique identifier for the transport

Log Level Mapping ​

LogLayerBunyan
tracetrace
debugdebug
infoinfo
warnwarn
errorerror
fatalfatal

Changelog ​

View the changelog here.