/** * Log entry structure */ export interface LogEntry { /** Log level */ level: LogLevel; /** Log message */ message: string; /** Additional arguments */ args: unknown[]; /** Timestamp */ timestamp: Date; /** Scope name (if any) */ scope?: string; /** Formatted log string */ formatted: string; } /** * Log levels in order of severity */ export declare enum LogLevel { DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3, NONE = 4 } /** * Custom log handler function type */ export type LogHandler = (entry: LogEntry) => void; /** * Logger configuration options */ export interface LoggerConfig { /** Minimum log level to output */ level: LogLevel; /** Global prefix for all log messages */ prefix: string; /** Custom log handler function */ handler?: LogHandler; /** 单条日志最大长度,防止输出被截断 */ maxOutputLength?: number; /** 是否使用数据摘要模式(减少输出量) */ useSummaryMode?: boolean; } /** * Logger class for consistent logging across the library * * @example * ```typescript * // Enable debug logging * Logger.setLevel(LogLevel.DEBUG); * * // Configure custom log handler * Logger.configure({ * handler: (entry) => { * // Send logs to a custom logging service * console.log(entry.formatted); * } * }); * * Logger.debug('Connecting to device', deviceId); * Logger.info('Print job started'); * Logger.warn('Retry attempt', { attempt: 2, maxRetries: 3 }); * Logger.error('Connection failed', error); * ``` */ export declare class Logger { private static config; /** * Configures the logger * * @param config - Configuration options */ static configure(config: Partial): void; /** * Sets the global log level * * @param level - Minimum log level to output */ static setLevel(level: LogLevel): void; /** * Gets the current log level */ static getLevel(): LogLevel; /** * Formats the log prefix */ private static formatPrefix; /** * Formats a complete log message for custom handlers */ private static formatMessage; /** * Logs a message with the specified level */ private static log; /** * Logs a debug message (only in DEBUG level) * * @param message - Message to log * @param args - Additional arguments to log */ static debug(message: string, ...args: unknown[]): void; /** * Logs an info message (DEBUG and INFO levels) * * @param message - Message to log * @param args - Additional arguments to log */ static info(message: string, ...args: unknown[]): void; /** * Logs a warning message (DEBUG, INFO, and WARN levels) * * @param message - Message to log * @param args - Additional arguments to log */ static warn(message: string, ...args: unknown[]): void; /** * Logs an error message (all levels except NONE) * * @param message - Message to log * @param args - Additional arguments to log */ static error(message: string, ...args: unknown[]): void; /** * Creates a scoped logger with a specific prefix * * @param scope - Scope name (e.g., 'BluetoothPrinter', 'TaroAdapter') * @returns Scoped logger instance */ static scope(scope: string): { debug: (message: string, ...args: unknown[]) => void; info: (message: string, ...args: unknown[]) => void; warn: (message: string, ...args: unknown[]) => void; error: (message: string, ...args: unknown[]) => void; }; }