summaryrefslogtreecommitdiff
path: root/index.js
blob: 82470284895dda07db9bd5cc25328dc313dc52fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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();