project setup

This commit is contained in:
Andrea Lamparelli 2022-12-06 18:10:30 +01:00
commit 05d156a5b0
39 changed files with 14823 additions and 0 deletions

View file

@ -0,0 +1,32 @@
import Logger from "@gb/service/logger/logger";
import LoggerService from "@gb/service/logger/logger-service";
export default class ConsoleLoggerService implements LoggerService {
private readonly logger;
constructor() {
this.logger = new Logger();
}
trace(message: string): void {
this.logger.log("[TRACE]", message);
}
debug(message: string): void {
this.logger.log("[DEBUG]", message);
}
info(message: string): void {
this.logger.log("[INFO]", message);
}
warn(message: string): void {
this.logger.log("[WARN]", message);
}
error(message: string): void {
this.logger.log("[ERROR]", message);
}
}

View file

@ -0,0 +1,18 @@
import ConsoleLoggerService from "@gb/service/logger/console-logger-service";
import LoggerService from "@gb/service/logger/logger-service";
/**
* Singleton factory class
*/
export default class LoggerServiceFactory {
private static instance?: LoggerService;
public static getLogger(): LoggerService {
if (!LoggerServiceFactory.instance) {
LoggerServiceFactory.instance = new ConsoleLoggerService();
}
return LoggerServiceFactory.instance;
}
}

View file

@ -0,0 +1,15 @@
/**
* Logger service interface providing the most commong logging functionalities
*/
export default interface LoggerService {
trace(message: string): void;
debug(message: string): void;
info(message: string): void;
warn(message: string): void;
error(message: string): void;
}

View file

@ -0,0 +1,15 @@
/**
* Common logger class based on the console.log functionality
*/
export default class Logger {
log(prefix: string, ...str: string[]) {
// eslint-disable-next-line no-console
console.log.apply(console, [prefix, ...str]);
}
emptyLine() {
this.log("", "");
}
}