twitch2ma
Version:
Twitch chat bot that runs commands on the MA GrandMA2 using Telnet.
48 lines • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
const chalk = require("chalk");
const Fs = require("fs");
const stripAnsi = require("strip-ansi");
class Logger {
setLogfile(logfile) {
this.end();
this.logfile = Fs.createWriteStream(logfile, { flags: "a" });
}
end() {
if (this.logfile) {
this.logfile.end();
}
}
toLogfile(message) {
if (this.logfile) {
this.logfile.write(stripAnsi(`${new Date().toISOString()} ${message}\n`));
}
}
error(message) {
console.error(chalk `❌ {bold.red ${message}}`);
this.toLogfile(`ERROR: ${message}`);
}
warning(message) {
console.warn(chalk `⚠️ {yellow ${message}}`);
this.toLogfile(`WARNING: ${message}`);
}
notice(message) {
console.log(chalk `ℹ️ {blue ${message}}`);
this.toLogfile(`NOTICE: ${message}`);
}
confirm(message) {
console.log(chalk `✅ {green ${message}}`);
this.toLogfile(`SUCCESS: ${message}`);
}
socketMessage(message) {
console.log(chalk `{inverse ${message}}`);
this.toLogfile(`=== ${message} ===`);
}
channelMessage(channel, message) {
console.log(chalk `{bgGreen.black ${channel} }: ${message}`);
this.toLogfile(`${channel}: ${message}`);
}
}
exports.Logger = Logger;
//# sourceMappingURL=Logger.js.map