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