mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
module.exports = {
|
|
GetDateString: GetDateString,
|
|
Log: Log,
|
|
GetColor: GetColor
|
|
};
|
|
|
|
var utils = require('./utils.js');
|
|
const nlogFile = "stats/nlogs";
|
|
|
|
function GetDateString() {
|
|
var m = new Date();
|
|
return m.getFullYear() + "/" +
|
|
("0" + (m.getMonth() + 1)).slice(-2) + "/" +
|
|
("0" + m.getDate()).slice(-2) + " " +
|
|
("0" + m.getHours()).slice(-2) + ":" +
|
|
("0" + m.getMinutes()).slice(-2) + ":" +
|
|
("0" + m.getSeconds()).slice(-2);
|
|
}
|
|
|
|
function Log(s, c, b) {
|
|
if (c != undefined)
|
|
console.log(c, GetDateString() + "> " + s);
|
|
else
|
|
console.log(GetDateString() + "> " + s);
|
|
|
|
if (b)
|
|
utils.Beep();
|
|
utils.AppendToFile(GetDateString() + "> " + s, nlogFile);
|
|
}
|
|
|
|
function GetColor(c) {
|
|
if (c == "redbg")
|
|
return '\x1b[41m%s\x1b[0m';
|
|
if (c == "bluebg")
|
|
return '\x1b[44m%s\x1b[0m';
|
|
if (c == "red")
|
|
return '\x1b[31m%s\x1b[0m';
|
|
if (c == "green")
|
|
return '\x1b[32m%s\x1b[0m';
|
|
if (c == "yellow")
|
|
return '\x1b[33m%s\x1b[0m';
|
|
if (c == "blue")
|
|
return '\x1b[34m%s\x1b[0m';
|
|
if (c == "cyan")
|
|
return '\x1b[36m%s\x1b[0m';
|
|
}
|