type LogLevel = 'debug' | 'info' | 'warn' | 'error'; class LoggerImpl { private enabled = false; private tag = 'TLRN'; init(options?: { enabled?: boolean; tag?: string }) { if (typeof options?.enabled === 'boolean') this.enabled = options.enabled; if (options?.tag) this.tag = options.tag; } setEnabled(enabled: boolean) { this.enabled = enabled; } setTag(tag: string) { this.tag = tag; } private format(level: LogLevel, message?: any, ...optional: any[]) { const prefix = `🎯 ${this.tag} [${level.toUpperCase()}]`; return [prefix, message, ...optional]; } debug(message?: any, ...optional: any[]) { if (!this.enabled) return; // eslint-disable-next-line no-console console.log(...this.format('debug', message, ...optional)); } info(message?: any, ...optional: any[]) { if (!this.enabled) return; // eslint-disable-next-line no-console console.log(...this.format('info', message, ...optional)); } warn(message?: any, ...optional: any[]) { // eslint-disable-next-line no-console console.warn(...this.format('warn', message, ...optional)); } error(message?: any, ...optional: any[]) { // eslint-disable-next-line no-console console.error(...this.format('error', message, ...optional)); } withTag(tag: string) { const child = new LoggerImpl(); child.init({ enabled: this.enabled, tag: `${this.tag}:${tag}` }); return child; } } export const Logger = new LoggerImpl();