Command-fix/logging.js

35 lines
880 B
JavaScript
Raw Normal View History

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