-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlogger.js
31 lines (26 loc) · 875 Bytes
/
logger.js
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
26
27
28
29
30
31
let colors = require("colors");
let events = require("events");
module.exports = logger = new events.EventEmitter();
let fill = function(str, len) {
while (str.length < len) str += " ";
return str;
}
logger.on("error", function (msg) {
console.log(`[${"ERROR".red}] ${msg}`);
});
logger.on("cmd", (cmd, args) => {
console.log(`[${cmd.blue}] ${args}`);
});
logger.on("log", (msg) => {
console.log(`[${" MSG ".green}] ${msg}`);
});
logger.on("chat", (room, user, msg) => {
if (msg.startsWith("/uhtml") || msg.startsWith("/raw")) return;
let longestRoom = 0;
for (let i in Rooms) {
if (i == "add") continue;
if (Rooms[i].name.length > longestRoom) longestRoom = Rooms[i].name.length;
}
let roompart = fill(Rooms[room].name, longestRoom);
console.log(`${roompart} | ${fill(user.trim(), 20)} | ${msg.trim()}`);
});