You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-26 22:13:53 +01:00
auth & console bugfixes
This commit is contained in:
29
console.js
29
console.js
@@ -1,17 +1,22 @@
|
||||
const { verboseMode } = require('./userconfig');
|
||||
|
||||
const MESSAGE_PREFIX = {
|
||||
INFO: "\x1b[32m[INFO]\x1b[0m",
|
||||
DEBUG: "\x1b[36m[DEBUG]\x1b[0m",
|
||||
};
|
||||
|
||||
const logInfo = (...messages) => console.log(MESSAGE_PREFIX.INFO, ...messages);
|
||||
const logDebug = (...messages) => {
|
||||
if (verboseMode) {
|
||||
console.log(MESSAGE_PREFIX.DEBUG, ...messages);
|
||||
}
|
||||
const getCurrentTime = () => {
|
||||
const currentTime = new Date();
|
||||
const hours = currentTime.getHours().toString().padStart(2, '0');
|
||||
const minutes = currentTime.getMinutes().toString().padStart(2, '0');
|
||||
return `\x1b[90m[${hours}:${minutes}]\x1b[0m`;
|
||||
};
|
||||
|
||||
const MESSAGE_PREFIX = {
|
||||
DEBUG: "\x1b[36m[DEBUG]\x1b[0m",
|
||||
INFO: "\x1b[32m[INFO]\x1b[0m",
|
||||
WARN: "\x1b[33m[WARN]\x1b[0m",
|
||||
};
|
||||
|
||||
const logDebug = (...messages) => verboseMode ? console.log(getCurrentTime(), MESSAGE_PREFIX.DEBUG, ...messages) : '';
|
||||
const logInfo = (...messages) => console.log(getCurrentTime(), MESSAGE_PREFIX.INFO, ...messages);
|
||||
const logWarn = (...messages) => console.log(getCurrentTime(), MESSAGE_PREFIX.WARN, ...messages);
|
||||
|
||||
module.exports = {
|
||||
logInfo, logDebug
|
||||
}
|
||||
logInfo, logDebug, logWarn
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user