Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ planned for 2026-01-01
### Updated

- [core] Update dependencies (#3909, #3916, #3921, #3925)
- [logger] Add prefixes to most Log messages (#3923)
- [logger] Add prefixes to most Log messages (#3923, #3926)

## [2.33.0] - 2025-10-01

Expand Down
4 changes: 2 additions & 2 deletions js/animateCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("[animateCSS] node not found for adding", element);
Log.warn("node not found for adding", element);
return;
}
node.style.setProperty("--animate-duration", `${animationTime}s`);
Expand All @@ -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("[animateCSS] node not found for removing", element);
Log.warn("node not found for removing", element);
return;
}
node.classList.remove("animate__animated", animationName);
Expand Down
8 changes: 4 additions & 4 deletions js/check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function checkConfigFile () {
}

// Validate syntax of the configuration file.
Log.info(`[checkconfig] Checking config file ${configFileName} ...`);
Log.info(`Checking config file ${configFileName} ...`);

// I'm not sure if all ever is utf-8
const configFile = fs.readFileSync(configFileName, "utf-8");
Expand All @@ -67,7 +67,7 @@ function checkConfigFile () {
);

if (errors.length === 0) {
Log.info(styleText("green", "[checkconfig] Your configuration file doesn't contain syntax errors :)"));
Log.info(styleText("green", "Your configuration file doesn't contain syntax errors :)"));
validateModulePositions(configFileName);
} else {
let errorMessage = "Your configuration file contains syntax errors :(";
Expand All @@ -84,7 +84,7 @@ function checkConfigFile () {
* @param {string} configFileName - The path and filename of the configuration file to validate.
*/
function validateModulePositions (configFileName) {
Log.info("[checkconfig] Checking modules structure configuration ...");
Log.info("Checking modules structure configuration ...");

const positionList = Utils.getModulePositions();

Expand Down Expand Up @@ -118,7 +118,7 @@ function validateModulePositions (configFileName) {

const valid = validate(data);
if (valid) {
Log.info(styleText("green", "[checkconfig] Your modules structure configuration doesn't contain errors :)"));
Log.info(styleText("green", "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];
Expand Down
8 changes: 4 additions & 4 deletions js/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function createWindow () {
try {
electronSize = electron.screen.getPrimaryDisplay().workAreaSize;
} catch {
Log.warn("[electron] Could not get display size, using defaults ...");
Log.warn("Could not get display size, using defaults ...");
}

let electronSwitchesDefaults = ["autoplay-policy", "no-user-gesture-required"];
Expand Down Expand Up @@ -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("[electron] Shutting down server...");
Log.log("Shutting down server...");
event.preventDefault();
setTimeout(() => {
process.exit(0);
Expand All @@ -215,7 +215,7 @@ app.on("certificate-error", (event, webContents, url, error, certificate, callba

if (process.env.clientonly) {
app.whenReady().then(() => {
Log.log("[electron] Launching client viewer application.");
Log.log("Launching client viewer application.");
createWindow();
});
}
Expand All @@ -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("[electron] Launching application.");
Log.log("Launching application.");
createWindow();
});
});
Expand Down
24 changes: 23 additions & 1 deletion js/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,30 @@

// add timestamps in front of log messages
require("console-stamp")(console, {
format: ":date(yyyy-mm-dd HH:MM:ss.l) :label(7) :msg",
format: ":date(yyyy-mm-dd HH:MM:ss.l) :label(7) :pre() :msg",
tokens: {
pre: () => {
const err = new Error();
Error.prepareStackTrace = (_, stack) => stack;
const stack = err.stack;
Error.prepareStackTrace = undefined;
try {
for (const line of stack) {
const file = line.getFileName();
if (file && !file.includes("node:") && !file.includes("js/logger.js") && !file.includes("node_modules")) {
const filename = file.replace(/.*\/(.*).js/, "$1");
const filepath = file.replace(/.*\/(.*)\/.*.js/, "$1");
if (filepath === "js") {
return styleText("grey", `[${filename}]`);
} else {
return styleText("grey", `[${filepath}]`);
}
}
}
} catch (err) {
return styleText("grey", "[unknown]");
}
},
label: (arg) => {
const { method, defaultTokens } = arg;
let label = defaultTokens.label(arg);
Expand Down
12 changes: 6 additions & 6 deletions js/node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const Class = require("./class");

const NodeHelper = Class.extend({
init () {
Log.log("[nodehelper] Initializing new module helper ...");
Log.log("Initializing new module helper ...");
},

loaded () {
Log.log(`[nodehelper] Module helper loaded: ${this.name}`);
Log.log(`Module helper loaded: ${this.name}`);
},

start () {
Log.log(`[nodehelper] Starting module helper: ${this.name}`);
Log.log(`Starting module helper: ${this.name}`);
},

/**
Expand All @@ -21,7 +21,7 @@ const NodeHelper = Class.extend({
* gracefully exit the module.
*/
stop () {
Log.log(`[nodehelper] Stopping module helper: ${this.name}`);
Log.log(`Stopping module helper: ${this.name}`);
},

/**
Expand All @@ -30,7 +30,7 @@ const NodeHelper = Class.extend({
* @param {object} payload The payload of the notification.
*/
socketNotificationReceived (notification, payload) {
Log.log(`[nodehelper] ${this.name} received a socket notification: ${notification} - Payload: ${payload}`);
Log.log(`${this.name} received a socket notification: ${notification} - Payload: ${payload}`);
},

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ const NodeHelper = Class.extend({
setSocketIO (io) {
this.io = io;

Log.log(`[nodehelper] Connecting socket for: ${this.name}`);
Log.log(`Connecting socket for: ${this.name}`);

io.of(this.name).on("connection", (socket) => {
// register catch all.
Expand Down
4 changes: 2 additions & 2 deletions modules/default/calendar/calendarfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn

try {
data = ical.parseICS(responseData);
Log.debug(`[calendar] parsed data=${JSON.stringify(data, null, 2)}`);
Log.debug(`parsed data=${JSON.stringify(data, null, 2)}`);
events = CalendarFetcherUtils.filterEvents(data, {
excludedEvents,
includePastEvents,
Expand Down Expand Up @@ -91,7 +91,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
* Broadcast the existing events.
*/
this.broadcastEvents = function () {
Log.info(`[calendar] Fetcher: Broadcasting ${events.length} events from ${url}.`);
Log.info(`Fetcher: Broadcasting ${events.length} events from ${url}.`);
eventsReceivedCallback(this);
};

Expand Down
40 changes: 20 additions & 20 deletions modules/default/calendar/calendarfetcherutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,26 @@ const CalendarFetcherUtils = {
const oneDayInMs = 24 * 60 * 60000;
let searchFromDate = pastLocalMoment.clone().subtract(Math.max(durationInMs, oneDayInMs), "milliseconds").toDate();
let searchToDate = futureLocalMoment.clone().add(1, "days").toDate();
Log.debug(`[calendar] Search for recurring events between: ${searchFromDate} and ${searchToDate}`);
Log.debug(`Search for recurring events between: ${searchFromDate} and ${searchToDate}`);

// if until is set, and its a full day event, force the time to midnight. rrule gets confused with non-00 offset
// looks like MS Outlook sets the until time incorrectly for fullday events
if ((rule.options.until !== undefined) && CalendarFetcherUtils.isFullDayEvent(event)) {
Log.debug("[calendar] fixup rrule until");
Log.debug("fixup rrule until");
rule.options.until = moment(rule.options.until).clone().startOf("day").add(1, "day")
.toDate();
}

Log.debug("[calendar] fix rrule start=", rule.options.dtstart);
Log.debug("[calendar] event before rrule.between=", JSON.stringify(event, null, 2), "exdates=", event.exdate);
Log.debug(`[calendar] RRule: ${rule.toString()}`);
Log.debug("fix rrule start=", rule.options.dtstart);
Log.debug("event before rrule.between=", JSON.stringify(event, null, 2), "exdates=", event.exdate);
Log.debug(`RRule: ${rule.toString()}`);
rule.options.tzid = null; // RRule gets *very* confused with timezones

let dates = rule.between(searchFromDate, searchToDate, true, () => {
return true;
});

Log.debug(`[calendar] Title: ${event.summary}, with dates: \n\n${JSON.stringify(dates)}\n`);
Log.debug(`Title: ${event.summary}, with dates: \n\n${JSON.stringify(dates)}\n`);

// shouldn't need this anymore, as RRULE not passed junk
dates = dates.filter((d) => {
Expand All @@ -140,7 +140,7 @@ const CalendarFetcherUtils = {
return CalendarFetcherUtils.isFullDayEvent(event) ? startMoment.startOf("day") : startMoment;
};

Log.debug(`[calendar] There are ${Object.entries(data).length} calendar entries.`);
Log.debug(`There are ${Object.entries(data).length} calendar entries.`);

const now = moment();
const pastLocalMoment = config.includePastEvents ? now.clone().startOf("day").subtract(config.maximumNumberOfDays, "days") : now;
Expand All @@ -153,10 +153,10 @@ const CalendarFetcherUtils = {
.subtract(1, "seconds");

Object.entries(data).forEach(([key, event]) => {
Log.debug("[calendar] Processing entry...");
Log.debug("Processing entry...");

const title = CalendarFetcherUtils.getTitleFromEvent(event);
Log.debug(`[calendar] title: ${title}`);
Log.debug(`title: ${title}`);

// Return quickly if event should be excluded.
let { excluded, eventFilterUntil } = this.shouldEventBeExcluded(config, title);
Expand All @@ -174,7 +174,7 @@ const CalendarFetcherUtils = {
}

if (event.type === "VEVENT") {
Log.debug(`[calendar] Event:\n${JSON.stringify(event, null, 2)}`);
Log.debug(`Event:\n${JSON.stringify(event, null, 2)}`);
let eventStartMoment = eventDate(event, "start");
let eventEndMoment;

Expand All @@ -191,12 +191,12 @@ const CalendarFetcherUtils = {
}
}

Log.debug(`[calendar] start: ${eventStartMoment.toDate()}`);
Log.debug(`[calendar] end: ${eventEndMoment.toDate()}`);
Log.debug(`start: ${eventStartMoment.toDate()}`);
Log.debug(`end: ${eventEndMoment.toDate()}`);

// Calculate the duration of the event for use with recurring events.
const durationMs = eventEndMoment.valueOf() - eventStartMoment.valueOf();
Log.debug(`[calendar] duration: ${durationMs}`);
Log.debug(`duration: ${durationMs}`);

const location = event.location || false;
const geo = event.geo || false;
Expand All @@ -217,12 +217,12 @@ const CalendarFetcherUtils = {

let dateKey = recurringEventStartMoment.tz("UTC").format("YYYY-MM-DD");

Log.debug("[calendar] event date dateKey=", dateKey);
Log.debug("event date dateKey=", dateKey);
// For each date that we're checking, it's possible that there is a recurrence override for that one day.
if (curEvent.recurrences !== undefined) {
Log.debug("[calendar] have recurrences=", curEvent.recurrences);
Log.debug("have recurrences=", curEvent.recurrences);
if (curEvent.recurrences[dateKey] !== undefined) {
Log.debug("[calendar] have a recurrence match for dateKey=", dateKey);
Log.debug("have a recurrence match for dateKey=", dateKey);
// We found an override, so for this recurrence, use a potentially different title, start date, and duration.
curEvent = curEvent.recurrences[dateKey];
// Some event start/end dates don't have timezones
Expand All @@ -237,12 +237,12 @@ const CalendarFetcherUtils = {
recurringEventEndMoment = moment(curEvent.end).tz(CalendarFetcherUtils.getLocalTimezone());
}
} else {
Log.debug("[calendar] recurrence key ", dateKey, " doesn't match");
Log.debug("recurrence key ", dateKey, " doesn't match");
}
}
// If there's no recurrence override, check for an exception date. Exception dates represent exceptions to the rule.
if (curEvent.exdate !== undefined) {
Log.debug("[calendar] have datekey=", dateKey, " exdates=", curEvent.exdate);
Log.debug("have datekey=", dateKey, " exdates=", curEvent.exdate);
if (curEvent.exdate[dateKey] !== undefined) {
// This date is an exception date, which means we should skip it in the recurrence pattern.
showRecurrence = false;
Expand All @@ -266,7 +266,7 @@ const CalendarFetcherUtils = {
}

if (showRecurrence === true) {
Log.debug(`[calendar] saving event: ${recurrenceTitle}`);
Log.debug(`saving event: ${recurrenceTitle}`);
newEvents.push({
title: recurrenceTitle,
startDate: recurringEventStartMoment.format("x"),
Expand All @@ -280,7 +280,7 @@ const CalendarFetcherUtils = {
description: description
});
} else {
Log.debug("[calendar] not saving event ", recurrenceTitle, eventStartMoment);
Log.debug("not saving event ", recurrenceTitle, eventStartMoment);
}
}
// End recurring event parsing.
Expand Down
8 changes: 4 additions & 4 deletions modules/default/calendar/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ const auth = {
pass: pass
};

Log.log("[calendar] Create fetcher ...");
Log.log("Create fetcher ...");

const fetcher = new CalendarFetcher(url, fetchInterval, [], maximumEntries, maximumNumberOfDays, auth);

fetcher.onReceive(function (fetcher) {
Log.log("[calendar] ", fetcher.events());
Log.log(fetcher.events());
process.exit(0);
});

fetcher.onError(function (fetcher, error) {
Log.log("[calendar] Fetcher error:", error);
Log.log("Fetcher error:", error);
process.exit(1);
});

fetcher.startFetch();

Log.log("[calendar] Create fetcher done! ");
Log.log("Create fetcher done! ");
Loading