Add logging framework with Logger, LoggerFactory, and appenders

- Introduced ILogger interface for logging methods
- Implemented Logger class with various logging levels and message formatting
- Created LoggerFactory for managing logger instances and appender configuration
- Added LoggingLevel enum and mapping for logging level types
- Developed ConsoleAppender and TechnikerMeAppender for different logging outputs
- Implemented appender management with AppenderFactory and base Appender class
- Established Threshold class for controlling logging levels
This commit is contained in:
2025-10-30 03:15:16 -04:00
parent cb34256276
commit 1587ed7428
12 changed files with 407 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import {assertUnreachable} from '@techniker-me/tools';
import {LoggingLevel, type LoggingLevelType} from './LoggingLevel';
export default class LoggingLevelMapping {
public static convertLoggingLevelToLoggingLevelType(loggingLevel: LoggingLevel): LoggingLevelType {
switch (loggingLevel) {
case LoggingLevel.Off:
return 'Off';
case LoggingLevel.Info:
return 'Info';
case LoggingLevel.Warn:
return 'Warn';
case LoggingLevel.Error:
return 'Error';
case LoggingLevel.Debug:
return 'Debug';
case LoggingLevel.Trace:
return 'Trace';
case LoggingLevel.Silly:
return 'Silly';
case LoggingLevel.All:
return 'All';
default:
assertUnreachable(loggingLevel);
}
}
public static convertLoggingLevelTypeToLoggingLevel(loggingLevelType: LoggingLevelType): LoggingLevel {
switch (loggingLevelType) {
case 'Off':
return LoggingLevel.Off;
case 'Info':
return LoggingLevel.Info;
case 'Warn':
return LoggingLevel.Warn;
case 'Error':
return LoggingLevel.Error;
case 'Debug':
return LoggingLevel.Debug;
case 'Trace':
return LoggingLevel.Trace;
case 'Silly':
return LoggingLevel.Silly;
case 'All':
return LoggingLevel.All;
default:
assertUnreachable(loggingLevelType);
}
}
}