Initial Commit

This commit is contained in:
2025-08-18 17:18:43 -04:00
commit 1bc3aaa8aa
17 changed files with 373 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { ConsoleAppender } from './appenders/ConsoleAppender';
import IAppender from './appenders/IAppender';
import {Logger} from './Logger';
import {LoggingLevel} from './LoggingLevel';
import {Threshold} from './Threshold';
export default class LoggerFactory {
private static readonly _loggerForCategory: Map<string, Logger> = new Map();
private static readonly _threshold: Threshold = new Threshold({level: LoggingLevel.Debug});
private static readonly _appenders: IAppender[] = [new ConsoleAppender()];
public static getLogger(category: string): Logger {
let logger = LoggerFactory._loggerForCategory.get(category);
if (logger === undefined) {
logger = new Logger({category, threshold: LoggerFactory._threshold, appenders: LoggerFactory._appenders});
LoggerFactory._loggerForCategory.set(category, logger);
}
return logger;
}
private constructor() {
throw new Error('[LoggerFactory] is a static class that may not be instantiated');
}
}