/** * @description 对console简单做一层封装,作为debug问题时使用 * */ interface LoggerFunc { (...args: unknown[]): void; } function createLogFunc(tag, type): LoggerFunc { return (...args: unknown[]) => { console[type](`[${tag}]`, ...args); } } export class DebugLogger { private tag: string; info: LoggerFunc; warn: LoggerFunc; error: LoggerFunc; constructor(tag) { this.tag = tag; this.info = createLogFunc(this.tag, 'info'); this.warn = createLogFunc(this.tag, 'warn'); this.error = createLogFunc(this.tag, 'error'); } } export default function createDebuggerLogger (tag) { return new DebugLogger(tag); }