UNPKG

@ackplus/react-tanstack-data-table

Version:

A powerful React data table component built with MUI and TanStack Table

77 lines 2.59 kB
/** * Logging utilities for the DataTable package. * * Provides a lightweight wrapper around `console` that can be configured globally * or per-instance to help troubleshoot behaviour in consuming applications. */ export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug'; interface ConsoleLike { debug?: (...args: unknown[]) => void; info?: (...args: unknown[]) => void; warn?: (...args: unknown[]) => void; error?: (...args: unknown[]) => void; log?: (...args: unknown[]) => void; } export interface DataTableLoggingOptions { /** * Whether logging should be enabled. */ enabled?: boolean; /** * Minimum level that will be emitted. Defaults to `warn`. */ level?: LogLevel; /** * Prefix prepended to every log message. Defaults to `DataTable`. */ prefix?: string; /** * Optional scope that will be appended after the prefix when present. */ scope?: string; /** * Include an ISO timestamp ahead of each log line. */ includeTimestamp?: boolean; /** * A custom logger implementation. Defaults to `console`. */ logger?: ConsoleLike; } type LoggerInput = boolean | DataTableLoggingOptions; type ResolvedLoggerConfig = Required<Omit<DataTableLoggingOptions, 'logger'>> & { logger: ConsoleLike; }; type LogMethodLevel = Exclude<LogLevel, 'silent'>; export interface LoggerInstance { debug: (...args: unknown[]) => void; info: (...args: unknown[]) => void; warn: (...args: unknown[]) => void; error: (...args: unknown[]) => void; /** * Create a new logger that inherits configuration and extends the scope. */ child: (scope: string, overrides?: LoggerInput) => LoggerInstance; /** * Check whether a level would emit given current configuration. */ isLevelEnabled: (level: LogMethodLevel) => boolean; /** * Access the resolved configuration for inspection. */ config: ResolvedLoggerConfig; } /** * Create a new logger instance. Configuration cascades from the global config unless overridden. */ export declare const createLogger: (scope?: string, input?: LoggerInput, parentConfig?: ResolvedLoggerConfig) => LoggerInstance; /** * Configure the global logger defaults for every DataTable instance. */ export declare const configureDataTableLogging: (options: DataTableLoggingOptions) => void; /** * Read the current global logging configuration. */ export declare const getDataTableLoggingConfig: () => ResolvedLoggerConfig; export {}; //# sourceMappingURL=logger.d.ts.map