mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-13 19:33:46 +00:00
refactor: escalate severe to electron
This commit is contained in:
committed by
Carlos Valente
parent
d41cd78f2e
commit
8742b790f3
@@ -8,19 +8,26 @@ import { consoleRed } from '../utils/console.js';
|
||||
|
||||
class Logger {
|
||||
private queue: Log[];
|
||||
private escalateErrorFn: (error: string) => void | null;
|
||||
|
||||
constructor() {
|
||||
this.queue = [];
|
||||
this.escalateErrorFn = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabling setup logger after init
|
||||
*/
|
||||
init() {
|
||||
init(escalateErrorFn: (error: string) => void) {
|
||||
this.queue.forEach((log) => {
|
||||
this._push(log);
|
||||
});
|
||||
this.queue = [];
|
||||
|
||||
// we only get this when running in electron
|
||||
if (escalateErrorFn) {
|
||||
this.escalateErrorFn = escalateErrorFn;
|
||||
}
|
||||
}
|
||||
|
||||
private addToQueue(log: Log) {
|
||||
@@ -105,6 +112,7 @@ class Logger {
|
||||
*/
|
||||
crash(origin: string, text: string) {
|
||||
this.emit(LogLevel.Severe, origin, text);
|
||||
this.escalateErrorFn?.(text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user