1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

logging improvements, connection changes, ui changes

This commit is contained in:
NoobishSVK
2024-02-07 20:18:38 +01:00
parent 0b11e9cd96
commit 8ad8015ae7
7 changed files with 108 additions and 87 deletions

View File

@@ -1,4 +1,5 @@
const verboseMode = process.argv.includes('--debug');
const verboseModeFfmpeg = process.argv.includes('--ffmpegdebug');
const getCurrentTime = () => {
const currentTime = new Date();
@@ -10,6 +11,7 @@ const getCurrentTime = () => {
const MESSAGE_PREFIX = {
DEBUG: "\x1b[36m[DEBUG]\x1b[0m",
ERROR: "\x1b[31m[ERROR]\x1b[0m",
FFMPEG: "\x1b[36m[FFMPEG]\x1b[0m",
INFO: "\x1b[32m[INFO]\x1b[0m",
WARN: "\x1b[33m[WARN]\x1b[0m",
};
@@ -38,6 +40,17 @@ const logError = (...messages) => {
console.log(logMessage);
};
const logFfmpeg = (...messages) => {
if (verboseModeFfmpeg) {
const logMessage = `${getCurrentTime()} ${MESSAGE_PREFIX.FFMPEG} ${messages.join(' ')}`;
logs.push(logMessage);
if (logs.length > maxLogLines) {
logs.shift(); // Remove the oldest log if the array exceeds the maximum number of lines
}
console.log(logMessage);
}
};
const logInfo = (...messages) => {
const logMessage = `${getCurrentTime()} ${MESSAGE_PREFIX.INFO} ${messages.join(' ')}`;
logs.push(logMessage);
@@ -57,5 +70,5 @@ const logWarn = (...messages) => {
};
module.exports = {
logError, logDebug, logInfo, logWarn, logs
logError, logDebug, logFfmpeg, logInfo, logWarn, logs
};