[logger] Add prefixes to most Log messages (#3923)

Co-authored-by: veeck <gitkraken@veeck.de>
This commit is contained in:
Veeck
2025-10-21 20:32:48 +02:00
committed by GitHub
parent f1c0c38c86
commit a1c1e9560c
34 changed files with 220 additions and 238 deletions

View File

@@ -132,7 +132,7 @@ function addAnimateCSS (element, animation, animationTime) {
const node = document.getElementById(element);
if (!node) {
// don't execute animate: we don't find div
Log.warn("addAnimateCSS: node not found for", element);
Log.warn("[animateCSS] node not found for adding", element);
return;
}
node.style.setProperty("--animate-duration", `${animationTime}s`);
@@ -149,7 +149,7 @@ function removeAnimateCSS (element, animation) {
const node = document.getElementById(element);
if (!node) {
// don't execute animate: we don't find div
Log.warn("removeAnimateCSS: node not found for", element);
Log.warn("[animateCSS] node not found for removing", element);
return;
}
node.classList.remove("animate__animated", animationName);

View File

@@ -44,7 +44,7 @@ function checkConfigFile () {
}
// Validate syntax of the configuration file.
Log.info(`Checking config file ${configFileName} ...`);
Log.info(`[checkconfig] Checking config file ${configFileName} ...`);
// I'm not sure if all ever is utf-8
const configFile = fs.readFileSync(configFileName, "utf-8");
@@ -67,7 +67,7 @@ function checkConfigFile () {
);
if (errors.length === 0) {
Log.info(styleText("green", "Your configuration file doesn't contain syntax errors :)"));
Log.info(styleText("green", "[checkconfig] Your configuration file doesn't contain syntax errors :)"));
validateModulePositions(configFileName);
} else {
let errorMessage = "Your configuration file contains syntax errors :(";
@@ -84,7 +84,7 @@ function checkConfigFile () {
* @param {string} configFileName - The path and filename of the configuration file to validate.
*/
function validateModulePositions (configFileName) {
Log.info("Checking modules structure configuration ...");
Log.info("[checkconfig] Checking modules structure configuration ...");
const positionList = Utils.getModulePositions();
@@ -118,7 +118,7 @@ function validateModulePositions (configFileName) {
const valid = validate(data);
if (valid) {
Log.info(styleText("green", "Your modules structure configuration doesn't contain errors :)"));
Log.info(styleText("green", "[checkconfig] Your modules structure configuration doesn't contain errors :)"));
} else {
const module = validate.errors[0].instancePath.split("/")[2];
const position = validate.errors[0].instancePath.split("/")[3];
@@ -130,13 +130,13 @@ function validateModulePositions (configFileName) {
} else {
errorMessage += validate.errors[0].message;
}
Log.error(errorMessage);
Log.error("[checkconfig]", errorMessage);
}
}
try {
checkConfigFile();
} catch (error) {
Log.error(error.message);
Log.error("[checkconfig]", error);
process.exit(1);
}

View File

@@ -40,7 +40,7 @@ function createWindow () {
try {
electronSize = electron.screen.getPrimaryDisplay().workAreaSize;
} catch {
Log.warn("Could not get display size, using defaults ...");
Log.warn("[electron] Could not get display size, using defaults ...");
}
let electronSwitchesDefaults = ["autoplay-policy", "no-user-gesture-required"];
@@ -196,7 +196,7 @@ app.on("activate", function () {
* core.stop() is called by process.on("SIGINT"... in `app.js`
*/
app.on("before-quit", async (event) => {
Log.log("Shutting down server...");
Log.log("[electron] Shutting down server...");
event.preventDefault();
setTimeout(() => {
process.exit(0);
@@ -215,7 +215,7 @@ app.on("certificate-error", (event, webContents, url, error, certificate, callba
if (process.env.clientonly) {
app.whenReady().then(() => {
Log.log("Launching client viewer application.");
Log.log("[electron] Launching client viewer application.");
createWindow();
});
}
@@ -228,7 +228,7 @@ if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].includes(co
core.start().then((c) => {
config = c;
app.whenReady().then(() => {
Log.log("Launching application.");
Log.log("[electron] Launching application.");
createWindow();
});
});

View File

@@ -268,7 +268,6 @@ const MM = (function () {
const hideModule = function (module, speed, callback, options = {}) {
// set lockString if set in options.
if (options.lockString) {
// Log.log("Has lockstring: " + options.lockString);
if (module.lockStrings.indexOf(options.lockString) === -1) {
module.lockStrings.push(options.lockString);
}

View File

@@ -38,7 +38,6 @@ const Module = Class.extend({
* Called when the module is instantiated.
*/
init () {
//Log.log(this.defaults);
},
/**
@@ -145,9 +144,9 @@ const Module = Class.extend({
*/
notificationReceived (notification, payload, sender) {
if (sender) {
// Log.log(this.name + " received a module notification: " + notification + " from sender: " + sender.name);
Log.debug(`${this.name} received a module notification: ${notification} from sender: ${sender.name}`);
} else {
// Log.log(this.name + " received a system notification: " + notification);
Log.debug(`${this.name} received a system notification: ${notification}`);
}
},

View File

@@ -4,15 +4,15 @@ const Class = require("./class");
const NodeHelper = Class.extend({
init () {
Log.log("Initializing new module helper ...");
Log.log("[nodehelper] Initializing new module helper ...");
},
loaded () {
Log.log(`Module helper loaded: ${this.name}`);
Log.log(`[nodehelper] Module helper loaded: ${this.name}`);
},
start () {
Log.log(`Starting module helper: ${this.name}`);
Log.log(`[nodehelper] Starting module helper: ${this.name}`);
},
/**
@@ -21,7 +21,7 @@ const NodeHelper = Class.extend({
* gracefully exit the module.
*/
stop () {
Log.log(`Stopping module helper: ${this.name}`);
Log.log(`[nodehelper] Stopping module helper: ${this.name}`);
},
/**
@@ -30,7 +30,7 @@ const NodeHelper = Class.extend({
* @param {object} payload The payload of the notification.
*/
socketNotificationReceived (notification, payload) {
Log.log(`${this.name} received a socket notification: ${notification} - Payload: ${payload}`);
Log.log(`[nodehelper] ${this.name} received a socket notification: ${notification} - Payload: ${payload}`);
},
/**
@@ -83,7 +83,7 @@ const NodeHelper = Class.extend({
setSocketIO (io) {
this.io = io;
Log.log(`Connecting socket for: ${this.name}`);
Log.log(`[nodehelper] Connecting socket for: ${this.name}`);
io.of(this.name).on("connection", (socket) => {
// register catch all.

View File

@@ -20,7 +20,7 @@ const Translator = (function () {
fileInfo = JSON.parse(xhr.responseText);
} catch (exception) {
// nothing here, but don't die
Log.error(` loading json file =${file} failed`);
Log.error(`[translator] loading json file =${file} failed`);
}
resolve(fileInfo);
}
@@ -67,22 +67,18 @@ const Translator = (function () {
}
if (this.translations[module.name] && key in this.translations[module.name]) {
// Log.log("Got translation for " + key + " from module translation: ");
return createStringFromTemplate(this.translations[module.name][key], variables);
}
if (key in this.coreTranslations) {
// Log.log("Got translation for " + key + " from core translation.");
return createStringFromTemplate(this.coreTranslations[key], variables);
}
if (this.translationsFallback[module.name] && key in this.translationsFallback[module.name]) {
// Log.log("Got translation for " + key + " from module translation fallback.");
return createStringFromTemplate(this.translationsFallback[module.name][key], variables);
}
if (key in this.coreTranslationsFallback) {
// Log.log("Got translation for " + key + " from core translation fallback.");
return createStringFromTemplate(this.coreTranslationsFallback[key], variables);
}
@@ -96,7 +92,7 @@ const Translator = (function () {
* @param {boolean} isFallback Flag to indicate fallback translations.
*/
async load (module, file, isFallback) {
Log.log(`${module.name} - Load translation${isFallback ? " fallback" : ""}: ${file}`);
Log.log(`[translator] ${module.name} - Load translation${isFallback ? " fallback" : ""}: ${file}`);
if (this.translationsFallback[module.name]) {
return;
@@ -113,10 +109,10 @@ const Translator = (function () {
*/
async loadCoreTranslations (lang) {
if (lang in translations) {
Log.log(`Loading core translation file: ${translations[lang]}`);
Log.log(`[translator] Loading core translation file: ${translations[lang]}`);
this.coreTranslations = await loadJSON(translations[lang]);
} else {
Log.log("Configured language not found in core translations.");
Log.log("[translator] Configured language not found in core translations.");
}
await this.loadCoreTranslationsFallback();
@@ -129,7 +125,7 @@ const Translator = (function () {
async loadCoreTranslationsFallback () {
let first = Object.keys(translations)[0];
if (first) {
Log.log(`Loading core translation fallback file: ${translations[first]}`);
Log.log(`[translator] Loading core translation fallback file: ${translations[first]}`);
this.coreTranslationsFallback = await loadJSON(translations[first]);
}
}