diff options
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/index.js b/index.js new file mode 100644 index 0000000..8247028 --- /dev/null +++ b/index.js @@ -0,0 +1,25 @@ +const Troffman = require('./src/Troffman'); +const winston = require('winston'); + +global.Logger = winston.createLogger({ + levels: winston.config.npm.levels, + format: winston.format.printf(info => { + let date = new Date(); + return `[${date.getDate()}/${(date.getMonth() + 1)}/${date.getFullYear()}-${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}][${info.level.toUpperCase()}] ${info.message}`; + }), +}); + +const bot = new Troffman('./config.toml'); + +if (bot.config.logging.console.enabled) { + Logger.add(new winston.transports.Console({ level: bot.config.logging.console.minimal })); +} + +if (bot.config.logging.file.enabled && bot.config.logging.file.path) { + Logger.add(new winston.transports.File({ filename: bot.config.logging.file.path, level: bot.config.logging.file.minimal })); + Logger.verbose(`Now logging to file ${bot.config.logging.file.path} with minimal level ${bot.config.logging.file.minimal}`); +} + +Logger.verbose('Connecting the bot'); + +bot.connect(); |
