Step 1: Basic container with manual registration
This commit is contained in:
23
DependencyInjection/src/Step1/Logger.ts
Normal file
23
DependencyInjection/src/Step1/Logger.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user