Files
SoftwareArchitecture/DependencyInjection/src/Step1/Logger.ts

24 lines
664 B
TypeScript

export class Logger {
private _category: string;
constructor(category: string) {
this._category = category;
}
public info(message: string, ...optionalArgs: unknown[]): void {
const formattedMessage = this.formatMessage('INFO', message);
console.log(formattedMessage, ...optionalArgs);
}
public error(message: string, ...optionalArgs: unknown[]): void {
const formattedMessage = this.formatMessage('ERROR', message);
console.error(formattedMessage, ...optionalArgs);
}
private formatMessage(level: string, message: string): string {
return `${new Date().toISOString()} [${this._category}] [${level}] ${message}`;
}
}