UNPKG

@debugg-ai/cli

Version:
168 lines 6.04 kB
/** * System-wide logging architecture with separate user and developer channels * * Set DEBUGGAI_LOG_LEVEL environment variable to control verbosity: * - ERROR: Only errors (default for production) * - WARN: Warnings and errors * - INFO: Info, warnings and errors (default) * - DEBUG: All logging including technical debug details (use for development only) * * Two main loggers: * - UserLogger: User-facing messages, progress, spinners, success/error notifications * - DevLogger: Technical details, debug info, API calls, git operations with context-aware categories * * Features: * - Git-aware truncation: NEVER logs actual diff content, only summaries * - API-specific truncation: Prevents response body logging, shows metadata only * - Context-aware limits: Different truncation limits for git/api/default contexts * - Array truncation: Shows counts instead of full arrays to prevent spam * - Special object handling: Extracts essential fields only, ignores large bodies * - Spinner management: Built-in ora spinner handling for user progress * * Usage: * - UserLogger.spinner.start('Processing...') - User-facing progress * - UserLogger.success('Tests completed') - User success messages * - UserLogger.error('Failed to connect') - User error messages * - DevLogger.git('Analyzing changes', data) - Git operations with safe truncation * - DevLogger.api('Making API call', requestInfo) - API operations * - DevLogger.tunnel('Starting tunnel', config) - Tunnel operations */ import { type Ora } from 'ora'; export declare enum LogLevel { ERROR = 0, WARN = 1, INFO = 2, DEBUG = 3 } declare class Logger { private level; private devMode; constructor(); isDevMode(): boolean; private shouldLog; error(message: string, data?: any, context?: 'default' | 'git' | 'api'): void; warn(message: string, data?: any, context?: 'default' | 'git' | 'api'): void; info(message: string, data?: any, context?: 'default' | 'git' | 'api'): void; debug(message: string, data?: any, context?: 'default' | 'git' | 'api'): void; success(message: string): void; progress(message: string): void; private truncate; } export declare const logger: Logger; export declare const gitLog: { info: (msg: string, data?: any) => void; debug: (msg: string, data?: any) => void; error: (msg: string, data?: any) => void; commitSummary: (commitHash: string, fileCount: number, message?: string) => void; changeSummary: (changes: any[]) => void; diffSize: (diffContent: string | undefined) => void; }; export declare const apiLog: { request: (method: string, url: string, data?: any) => void; response: (response: any, timing?: number) => void; error: (error: any, context?: string) => void; debug: (msg: string, data?: any) => void; info: (msg: string, data?: any) => void; }; /** * UserLogger - For user-facing messages, progress indicators, and notifications * Always visible to users regardless of log level (except for debug messages) */ declare class UserLoggerClass { private currentSpinner; /** * Spinner management for user progress indication */ spinner: { start: (message: string) => Ora; succeed: (message?: string) => void; fail: (message?: string) => void; stop: () => void; update: (message: string) => void; }; /** * Success messages - always shown to users */ success(message: string): void; /** * Error messages - always shown to users */ error(message: string): void; /** * Warning messages - always shown to users */ warn(message: string): void; /** * Info messages - shown to users (not for technical details) */ info(message: string): void; /** * Progress messages - shown during operations */ progress(message: string): void; } /** * DevLogger - For technical debug information, API calls, git operations * Respects log level settings and provides context-aware truncation */ declare class DevLoggerClass { private level; constructor(); private shouldLog; private truncate; /** * Git operations logging - NEVER logs actual diff content */ git(message: string, data?: any): void; /** * API operations logging - prevents response body logging */ api(message: string, data?: any): void; /** * Tunnel operations logging */ tunnel(message: string, data?: any): void; /** * General debug logging */ debug(message: string, data?: any): void; /** * Info level logging for technical details */ info(message: string, data?: any): void; /** * Warning level logging for technical issues */ warn(message: string, data?: any): void; /** * Error level logging for technical errors */ error(message: string, data?: any): void; } export declare const UserLogger: UserLoggerClass; export declare const DevLogger: DevLoggerClass; export declare const log: { error: (msg: string, data?: any) => void; warn: (msg: string, data?: any) => void; info: (msg: string, data?: any) => void; debug: (msg: string, data?: any) => void; success: (msg: string) => void; progress: (msg: string) => void; git: { info: (msg: string, data?: any) => void; debug: (msg: string, data?: any) => void; error: (msg: string, data?: any) => void; commitSummary: (commitHash: string, fileCount: number, message?: string) => void; changeSummary: (changes: any[]) => void; diffSize: (diffContent: string | undefined) => void; }; api: { request: (method: string, url: string, data?: any) => void; response: (response: any, timing?: number) => void; error: (error: any, context?: string) => void; debug: (msg: string, data?: any) => void; info: (msg: string, data?: any) => void; }; }; export {}; //# sourceMappingURL=logging.d.ts.map