Command-fix/logging.js

34 lines
713 B
JavaScript
Raw Normal View History

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