From 405051211d60afa8a7fc4fc3fa5ffb456242973d Mon Sep 17 00:00:00 2001 From: Alejandro Sior Date: Fri, 19 Feb 2021 11:43:18 +0100 Subject: initial commit --- index.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 index.js (limited to 'index.js') 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(); -- cgit v1.2.3