diff --git a/config/default.json b/config/default.json index 0d6d08c..3a72ac1 100644 --- a/config/default.json +++ b/config/default.json @@ -1,4 +1,5 @@ { + "logdnaKey": "", "commandPrefix": ".", "logChannel": null, "clientLoginToken": null, diff --git a/logging.js b/logging.js index 9d6b7b3..c42a636 100644 --- a/logging.js +++ b/logging.js @@ -3,24 +3,28 @@ winston.emitErrs = true; var logger = new winston.Logger({ transports: [ - new winston.transports.File({ - level: 'info', - filename: './server.log', - handleExceptions: true, - humanReadableUnhandledException: true, - json: true, - maxsize: 5242880, //5MB - maxFiles: 5, - colorize: false - }), new winston.transports.Console({ - level: 'debug', - handleExceptions: true, - json: false, - colorize: true + level: 'silly', + handleExceptions: true, + humanReadableUnhandledException: true, + json: false, + colorize: true }) ], + handleExceptions: true, exitOnError: false }); +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.'); +} + module.exports = logger; diff --git a/package.json b/package.json index 11cb326..92cdcfe 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "dependencies": { "config": "^1.24.0", "discord.js": "^10.0.1", + "logdna": "^1.2.3", "request": "^2.79.0", "winston": "^2.3.0" } diff --git a/start.sh b/start.sh old mode 100644 new mode 100755