Files
ChannelTests-TS/test/logger/LoggingLevel.ts
Alexander Zinn 3875b3878d Refactor logging level handling and remove example usage
* Updated `CommandLineOptions` and `ConfigurationObject` to use `LoggingLevel` type instead of string for log levels.
* Modified `LoggerFactory` to set logging levels using the new `LoggingLevelMapping` methods.
* Removed the `example-usage.ts` file as it was no longer needed.
* Adjusted `Threshold` class to simplify logging level management.
2025-08-18 18:22:38 -04:00

61 lines
1.6 KiB
TypeScript

export enum LoggingLevel {
Off = 0,
Fatal = 1,
Error = 2,
Warning = 3,
Info = 4,
Debug = 5,
Trace = 6,
All = 7
}
export type LoggingLevelType = 'off' | 'fatal' | 'error' | 'warning' | 'info' | 'debug' | 'trace' | 'all';
export class LoggingLevelMapping {
public static convertLoggingLevelToLoggingLevelType(level: LoggingLevel): LoggingLevelType {
switch (level) {
case LoggingLevel.Off:
return 'off';
case LoggingLevel.Fatal:
return 'fatal';
case LoggingLevel.Error:
return 'error';
case LoggingLevel.Warning:
return 'warning';
case LoggingLevel.Info:
return 'info';
case LoggingLevel.Debug:
return 'debug';
case LoggingLevel.Trace:
return 'trace';
case LoggingLevel.All:
return 'all';
default:
throw new Error(`[LoggingLevelMapping] Received unknown logging level [${level}]`);
}
}
public static convertLoggingLevelTypeToLoggingLevel(level: LoggingLevelType): LoggingLevel {
switch (level) {
case 'off':
return LoggingLevel.Off;
case 'fatal':
return LoggingLevel.Fatal;
case 'error':
return LoggingLevel.Error;
case 'warning':
return LoggingLevel.Warning;
case 'info':
return LoggingLevel.Info;
case 'debug':
return LoggingLevel.Debug;
case 'trace':
return LoggingLevel.Trace;
case 'all':
return LoggingLevel.All;
default:
throw new Error(`[LoggingLevelMapping] Received unknown logging level type [${level}]`);
}
}
}