fix: crash-log not written on windows and add log entries to crash report

* fix: crashlog not written on windows

* feat: dump last 100 log entries to crash report
This commit is contained in:
Alex Christoffer Rasmussen
2026-01-01 14:59:21 +01:00
committed by GitHub
parent 75e77de466
commit 680273770c
2 changed files with 15 additions and 2 deletions
+11 -1
View File
@@ -53,10 +53,11 @@ class Logger {
}
}
this.addToQueue(log);
try {
socket.sendAsJson(MessageTag.Log, log);
} catch (_e) {
this.addToQueue(log);
/* Nothing to catch */
}
}
@@ -117,6 +118,15 @@ class Logger {
this.escalateErrorFn?.(text, true);
}
/**
* Dumps the last 100 log entries
*/
dump() {
const q = this.queue;
this.queue = [];
return q;
}
/**
* Shutdown logger
*/
+4 -1
View File
@@ -7,6 +7,7 @@ import { publicDir } from '../setup/index.js';
import { ensureDirectory } from './fileManagement.js';
import { getCurrentRundown } from '../api-data/rundown/rundown.dao.js';
import { logger } from '../classes/Logger.js';
/**
* Writes a file to the crash report location
* @param fileName
@@ -29,9 +30,10 @@ function writeToFile(fileName: string, content: object) {
* @param error
*/
export function generateCrashReport(maybeError: unknown) {
const timeNow = new Date().toISOString();
const timeNow = new Date().toISOString().replaceAll(':', '_');
const runtimeState = getState();
const currentRundown = getCurrentRundown();
const log = logger.dump();
const error =
maybeError instanceof Error
? {
@@ -44,6 +46,7 @@ export function generateCrashReport(maybeError: unknown) {
time: timeNow,
version: ONTIME_VERSION,
error,
log: log,
runtimeState,
currentRundown,
};