Miss any of our Open RFC calls?Watch the recordings here! »

@ambassify/bunyan-logger

3.0.8 • Public • Published

bunyan-logger

A drop-in replacement logger for console which logs to Loggly and the console. It includes support for CommonJS as well as ES Modules and has optimized builds for the browser. These are exposed through the various package.json entrypoints.

Usage

CommonJS

const createLogger = require('@ambassify/bunyan-logger');
const console = createLogger({ /* options */ });
 
// or to get a preconfigured logger based on your environment
const console = require('@ambassify/bunyan-logger/default');
 
console.log('test'); // Logs to console and Loggly

ES Modules

import createLogger from '@ambassify/bunyan-logger';
const console = createLogger({ /* options */ });
 
// or to get a preconfigured logger based on your environment
import console from '@ambassify/bunyan-logger/default.esm';
 
console.log('test'); // Logs to console and Loggly

Options

Name Type Description
name String Name for your logger. Required.
notify Boolean Whether or not to output a log when a stream is enabled. Defaults to true. Can be overridden per stream.
level String Minimal log level that gets emitted, lower levels are ignored. Can be overridden per stream.
fields Object You can pass default fields for the logger here, these will be included on every log record.
stdout Object Options for the console logger. Set to false to disable.
serializers Object Bunyan serializers. The default serializers are always added.
logUnhandled Boolean Whether or not to log unhandled errors, promise rejections, window.onerror events, ... Defaults to false.
stdout.pretty boolean Whether or not to output pretty logs instead of raw JSON. Defaults to true.
stdout.level String Minimal log level that gets emitted, lower levels are ignored.
stdout.notify boolean Whether or not to output a log when this stream is enabled. Defaults to true.
loggly Object Options for the loggly logger. Set to false to disable.
loggly.token string Loggly customer token. Required.
loggly.subdomain string Loggly subdomain. Required in node environment, ignored in the browser.
loggly.tags Array Tags to add to your loggly logs.
loggly.level String Minimal log level that gets emitted, lower levels are ignored.
loggly.notify boolean Whether or not to output a log when this stream is enabled. Defaults to true.

Keywords

Install

npm i @ambassify/bunyan-logger

DownloadsWeekly Downloads

57

Version

3.0.8

License

MIT

Unpacked Size

1.19 MB

Total Files

344

Last publish

Collaborators

  • avatar