@ambassify/bunyan-logger

3.1.6 • Public • Published

bunyan-logger

A drop-in replacement logger for console which logs to graylog 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 graylog

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 graylog

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.
graylog Object Options for the GELF logger. Set to false to disable.
graylog.endpoint string GELF endpoint of the graylog instance. Required.
graylog.tags Array Tags to add to your graylog logs.
graylog.level String Minimal log level that gets emitted, lower levels are ignored.
graylog.notify boolean Whether or not to output a log when this stream is enabled. Defaults to true.

Readme

Keywords

Package Sidebar

Install

npm i @ambassify/bunyan-logger

Weekly Downloads

41

Version

3.1.6

License

MIT

Unpacked Size

101 kB

Total Files

50

Last publish

Collaborators

  • ambassify