UNPKG

mframejs

Version:
32 lines 797 B
let loggerActive = false; let id = 10000; let defaultLog; export class Logger { constructor(name, category) { this.id = id; id++; this.name = name; this.category = category || 'unamed'; } static getLogger(name, category) { if (loggerActive) { return new Logger(name, category); } else { return defaultLog; } } static enable() { loggerActive = true; } static disable() { loggerActive = false; } log(...msg) { if (loggerActive) { console.warn(`Log[${this.id}] - [${this.category}] - [${this.name}] `, msg.join(' - ')); } } } defaultLog = new Logger('na', 'na'); //# sourceMappingURL=logger.js.map