UNPKG

hd-utils

Version:

A handy utils for modern JS developers

30 lines (29 loc) 884 B
import { ConsoleRecord } from '../utils/types'; /** * @description A utility to record all logs 'error' | 'log' | 'info' | 'table' | 'warn', will save them to an object logRecord with time. * @example const logManager = new ConsoleRecorder(); * console.log("foo"); * logManager.logRecord.log // [{time:"123", value:["foo"]}] */ export default class ConsoleRecorder { private oldestLog; private oldestInfo; private oldestError; private oldestWarn; private oldestTable; private _logRecord; constructor(options?: { error?: boolean; info?: boolean; log?: boolean; table?: boolean; warn?: boolean; }); recordLog: () => void; recordError: () => void; recordInfo: () => void; recordWarn: () => void; recordTable: () => void; get logRecord(): ConsoleRecord; stopAllRecord: () => void; }