UNPKG

@nlabs/arkhamjs-middleware-logger

Version:

Add console logging for ArkhamJS

65 lines 2.67 kB
import type { FluxAction } from '@nlabs/arkhamjs'; export declare const LoggerDebugLevel: { readonly DISABLED: 0; readonly LOGS: 1; readonly DISPATCH: 2; }; export type LoggerDebugLevelType = typeof LoggerDebugLevel[keyof typeof LoggerDebugLevel]; export interface LoggerOptions { readonly debugLevel?: LoggerDebugLevelType; readonly debugErrorFnc?: (debugLevel: number, ...args: any[]) => void; readonly debugInfoFnc?: (debugLevel: number, ...args: any[]) => void; readonly debugLogFnc?: (debugLevel: number, ...args: any[]) => void; } export declare class Logger { name: string; private previousStore; private defaultOptions; private options; constructor(options: LoggerOptions); /** * Set configuration options. * * @param {object} options Configuration options. */ config(options: LoggerOptions): void; /** * Logs errors in the console. Will also call the debugErrorFnc method set in the config. * * @param {object} obj A list of JavaScript objects to output. The string representations of each of these objects * are appended together in the order listed and output. */ debugError(...obj: any[]): void; /** * Logs informational messages to the console. Will also call the debugInfoFnc method set in the config. * * @param {object} obj A list of JavaScript objects to output. The string representations of each of these objects * are appended together in the order listed and output. */ debugInfo(...obj: any[]): void; /** * Logs data in the console. Only logs when in debug mode. Will also call the debugLogFnc method set in the config. * * @param {object} obj A list of JavaScript objects to output. The string representations of each of these objects * are appended together in the order listed and output. */ debugLog(...obj: any[]): void; /** * Enables the console debugger. * * @param {number} level Enable or disable the debugger. Uses the constants: * LoggerDebugLevel.DISABLED (0) - Disable. * LoggerDebugLevel.LOGS (1) - Enable console logs. * LoggerDebugLevel.DISPATCH (2) - Enable console logs and dispatch action data (default). */ enableDebugger(level?: LoggerDebugLevelType): void; /** * Get the current FluxLogger options. * * @returns {LoggerOptions} the FluxLogger options object. */ getOptions(): LoggerOptions; preDispatch(action: FluxAction, store: any): Promise<FluxAction>; postDispatch(action: FluxAction, store: object): Promise<FluxAction>; } //# sourceMappingURL=Logger.d.ts.map