0.0.3 • Published 7 years ago
bunyan-discord v0.0.3
bunyan-discord
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