2017-03-14 23:58:17 -04:00
|
|
|
var config = require('config');
|
2016-12-07 22:52:37 -05:00
|
|
|
var winston = require('winston');
|
2017-03-14 23:59:40 -04:00
|
|
|
var logdna = require('logdna');
|
|
|
|
var ip = require('ip');
|
|
|
|
var os = require("os");
|
2016-12-07 22:52:37 -05:00
|
|
|
|
2017-03-14 23:59:40 -04:00
|
|
|
winston.emitErrs = true;
|
2016-12-07 22:52:37 -05:00
|
|
|
var logger = new winston.Logger({
|
|
|
|
transports: [
|
|
|
|
new winston.transports.Console({
|
2017-07-08 23:48:58 -04:00
|
|
|
level: 'warn',
|
2017-03-14 23:55:22 -04:00
|
|
|
handleExceptions: true,
|
|
|
|
humanReadableUnhandledException: true,
|
|
|
|
json: false,
|
|
|
|
colorize: true
|
2017-07-08 23:48:58 -04:00
|
|
|
}),
|
|
|
|
new winston.transports.File({
|
|
|
|
filename: 'discord.log',
|
|
|
|
level: 'silly'
|
2016-12-07 22:52:37 -05:00
|
|
|
})
|
|
|
|
],
|
2017-03-14 23:55:22 -04:00
|
|
|
handleExceptions: true,
|
2016-12-07 22:52:37 -05:00
|
|
|
exitOnError: false
|
|
|
|
});
|
|
|
|
|
2017-04-07 19:22:57 -04:00
|
|
|
if (process.env.NODE_ENV == 'production' && config.logdnaKey) {
|
2017-03-14 23:55:22 -04:00
|
|
|
// Setup logging for LogDNA cloud logging.
|
|
|
|
logger.add(winston.transports.Logdna, {
|
2017-03-15 00:03:38 -04:00
|
|
|
level: 'info',
|
2017-03-14 23:55:22 -04:00
|
|
|
key: config.logdnaKey,
|
|
|
|
ip: ip.address(),
|
|
|
|
hostname: os.hostname(),
|
|
|
|
app: 'services-discordbot'
|
|
|
|
});
|
|
|
|
logger.info('[logging] Started LogDNA winston transport.');
|
|
|
|
}
|
|
|
|
|
2016-12-07 22:52:37 -05:00
|
|
|
module.exports = logger;
|