mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 09:23:51 +00:00
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:
committed by
GitHub
parent
75e77de466
commit
680273770c
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user