mirror of
https://github.com/cpvalente/ontime.git
synced 2026-07-26 10:38:55 +00:00
refactor: add severe log level
This commit is contained in:
committed by
Carlos Valente
parent
715600a514
commit
d41cd78f2e
@@ -270,13 +270,13 @@ process.on('exit', (code) => console.log(`Ontime shutdown with code: ${code}`));
|
||||
|
||||
process.on('unhandledRejection', async (error) => {
|
||||
generateCrashReport(error);
|
||||
logger.error(LogOrigin.Server, `Uncaught exception | ${error}`);
|
||||
logger.crash(LogOrigin.Server, `Uncaught exception | ${error}`);
|
||||
await shutdown(1);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', async (error) => {
|
||||
generateCrashReport(error);
|
||||
logger.error(LogOrigin.Server, `Uncaught exception | ${error}`);
|
||||
logger.crash(LogOrigin.Server, `Uncaught exception | ${error}`);
|
||||
await shutdown(1);
|
||||
});
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ class Logger {
|
||||
* @param log
|
||||
*/
|
||||
private _push(log: Log) {
|
||||
if (!isProduction || log.level === LogLevel.Error) {
|
||||
if (log.level === LogLevel.Error) {
|
||||
if (!isProduction || log.level === LogLevel.Severe) {
|
||||
if (log.level === LogLevel.Severe) {
|
||||
consoleRed(`[${log.level}] \t ${log.origin} \t ${log.text}`);
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
@@ -98,6 +98,15 @@ class Logger {
|
||||
this.emit(LogLevel.Error, origin, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to emit logging message of type SEVERE
|
||||
* @param origin
|
||||
* @param text
|
||||
*/
|
||||
crash(origin: string, text: string) {
|
||||
this.emit(LogLevel.Severe, origin, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown logger
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@ export enum LogLevel {
|
||||
Info = 'INFO',
|
||||
Warn = 'WARN',
|
||||
Error = 'ERROR',
|
||||
Severe = 'SEVERE',
|
||||
}
|
||||
|
||||
export type Log = {
|
||||
|
||||
Reference in New Issue
Block a user