Command-fix/logging.js

33 lines
774 B
JavaScript
Raw Normal View History

2017-08-03 01:48:16 +00:00
const winston = require('winston');
const ip = require('ip');
const os = require("os");
const logdna = require('logdna');
2016-12-08 03:52:37 +00:00
2017-03-15 03:59:40 +00:00
winston.emitErrs = true;
var logger = new winston.Logger({
level: 'debug',
2016-12-08 03:52:37 +00:00
transports: [
new (winston.transports.Console)(),
2016-12-08 03:52:37 +00:00
],
2017-03-15 03:55:22 +00:00
handleExceptions: true,
2017-08-03 01:48:16 +00:00
humanReadableUnhandledException: true,
exitOnError: false,
meta: true
2016-12-08 03:52:37 +00:00
});
// Setup logging for LogDNA cloud logging.
if (process.env.LOGDNA_API_KEY) {
2017-03-15 03:55:22 +00:00
logger.add(winston.transports.Logdna, {
2017-03-15 04:03:38 +00:00
level: 'info',
app: 'discord-bot',
2017-08-03 01:48:16 +00:00
index_meta: true,
key: process.env.LOGDNA_API_KEY,
2017-03-15 03:55:22 +00:00
ip: ip.address(),
hostname: os.hostname()
2017-03-15 03:55:22 +00:00
});
logger.info('Started LogDNA winston transport.');
2017-03-15 03:55:22 +00:00
}
2016-12-08 03:52:37 +00:00
module.exports = logger;