import { InsightLogger, UnknownRecord } from './InsightLogger'; import { LogType } from '../logger'; type LoggerFunc = ( message?: string, data?: string | number | UnknownRecord, other?: UnknownRecord ) => void; export class QuickLogger { emerg: LoggerFunc; error: LoggerFunc; warn: LoggerFunc; info: LoggerFunc; debug: LoggerFunc; protected insightLogger: InsightLogger; protected event: string; constructor(insightLogger, { event }) { this.event = event; this.insightLogger = insightLogger; this.emerg = this.createLogFunc('emerg'); this.error = this.createLogFunc('error'); this.warn = this.createLogFunc('warn'); this.info = this.createLogFunc('info'); this.debug = this.createLogFunc('debug'); } private createLogFunc(type: LogType): LoggerFunc { return (message, data, other) => { const fn = this.insightLogger[type]; return fn.call(this.insightLogger, { ...other, event: this.event, data, message, }); }; } }