0.0.3 • Published 7 years ago

bunyan-discord v0.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

bunyan-discord

bunyan-discord bunyan-discord bunyan-discord Build Status

Bunyan stream for Discord chat integration

Install bunyan and bunyan-discord

npm install bunyan bunyan-discord

Basic Setup

const bunyan = require('bunyan');
const BunyanDiscord = require('bunyan-discord');

const logger = bunyan.createLogger({
	name: 'myApp',
	stream: new BunyanDiscord({
		webhookUrl: 'your_webhook_url'
	}),
	level: 'error'
});

log.error('hello bunyan discord');

Error Handler

You can also pass an optional error handler.

new BunyanDiscord({
	webhookUrl: 'your_webhook_url'
}, err => {
	console.log(err);
});

Custom Formatters

By default the logs are formatted like so: [LOG_LEVEL] message, unless you specify a format function.

const logger = bunyan.createLogger({
	name: 'myApp',
	stream: new BunyanDiscord({
		webhookUrl: 'your_webhook_url',
    format: r => `(${r.levelName.toLowerCase()}): ${r.msg[0].toUpperCase() + r.msg.slice(1)}`
	}),
	level: 'error'
});

This library was adapted from bunyan-slack

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago