|
1 | 1 | const Bot = require(`./Bot`);
|
| 2 | +const winston = require('winston'); |
| 3 | + |
| 4 | +const logDate = new Date().toISOString(); |
| 5 | +var fs = require( 'fs' ); |
| 6 | +var logDir = 'logs'; |
| 7 | +if ( !fs.existsSync( logDir ) ) { |
| 8 | + fs.mkdirSync( logDir ); |
| 9 | +} |
| 10 | +const logger = winston.createLogger({ |
| 11 | + level: 'info', |
| 12 | + format: winston.format.json(), |
| 13 | + transports: [ |
| 14 | + new winston.transports.File({ filename: `./${logDir}/${logDate}_error.log`, level: 'error' }), |
| 15 | + new winston.transports.File({ filename: `./${logDir}/${logDate}_combined.log` }), |
| 16 | + ], |
| 17 | +}); |
| 18 | + |
| 19 | +logger.add(new winston.transports.Console({ |
| 20 | + format: winston.format.simple(), |
| 21 | +})); |
| 22 | + |
| 23 | +console.log = function(){ |
| 24 | + return logger.info.apply(logger, arguments) |
| 25 | +} |
| 26 | +console.error = function(){ |
| 27 | + return logger.error.apply(logger, arguments) |
| 28 | +} |
| 29 | +console.info = function(){ |
| 30 | + return logger.warn.apply(logger, arguments) |
| 31 | +} |
2 | 32 |
|
3 | 33 | const DiscordBot = new Bot();
|
4 | 34 |
|
5 | 35 | // Handle graceful shutdowns
|
6 |
| -process.on(`SIGINT`, cleanup); |
7 |
| -process.on(`SIGTERM`, cleanup); |
| 36 | +// process.on(`SIGINT`, cleanup); |
| 37 | +// process.on(`SIGTERM`, cleanup); |
8 | 38 |
|
9 | 39 | function cleanup() {
|
10 | 40 | DiscordBot.destroy();
|
|
0 commit comments