a11yanalyze
Version:
A command-line tool for developers and QA engineers to test web pages and websites for WCAG 2.2 AA accessibility compliance
297 lines • 8.47 kB
TypeScript
/**
* Error Logging and Technical Issue Reporting System
* Provides comprehensive error tracking, logging, and technical diagnostics
*/
/**
* Error severity levels
*/
export type ErrorLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
/**
* Error categories for classification
*/
export type ErrorCategory = 'browser' | 'network' | 'parsing' | 'timeout' | 'validation' | 'configuration' | 'scanning' | 'crawling' | 'output' | 'system' | 'unknown';
/**
* Structured error entry
*/
export interface ErrorEntry {
/** Unique error identifier */
id: string;
/** Error severity level */
level: ErrorLevel;
/** Error category */
category: ErrorCategory;
/** Human-readable error message */
message: string;
/** Technical details */
details?: string;
/** Error stack trace */
stack?: string;
/** Associated URL if applicable */
url?: string;
/** Timestamp when error occurred */
timestamp: string;
/** Source component that generated the error */
source: string;
/** Additional context data */
context?: Record<string, any>;
/** Recovery action taken */
recoveryAction?: string;
/** Whether error was recovered from */
recovered: boolean;
}
/**
* Technical issue report
*/
export interface TechnicalIssue {
/** Issue identifier */
id: string;
/** Issue type */
type: 'performance' | 'compatibility' | 'resource' | 'security' | 'accessibility' | 'other';
/** Issue severity */
severity: 'low' | 'medium' | 'high' | 'critical';
/** Issue title */
title: string;
/** Detailed description */
description: string;
/** Affected URLs */
affectedUrls: string[];
/** Reproduction steps */
reproductionSteps?: string[];
/** Suggested fixes */
suggestedFixes: string[];
/** Technical details */
technicalDetails: Record<string, any>;
/** First occurrence */
firstOccurrence: string;
/** Last occurrence */
lastOccurrence: string;
/** Occurrence count */
occurrenceCount: number;
}
/**
* System diagnostics information
*/
export interface SystemDiagnostics {
/** System information */
system: {
platform: string;
arch: string;
nodeVersion: string;
memory: {
total: number;
used: number;
percentage: number;
};
cpu: {
model: string;
cores: number;
usage?: number;
};
};
/** Browser information */
browser: {
name: string;
version: string;
executablePath?: string;
userAgent: string;
};
/** Network information */
network: {
connectivity: 'online' | 'offline' | 'limited';
dnsResolution: boolean;
responseTime?: number;
};
/** Tool configuration */
configuration: {
scanOptions: Record<string, any>;
crawlOptions: Record<string, any>;
outputOptions: Record<string, any>;
};
}
/**
* Error logging configuration
*/
export interface ErrorLoggerConfig {
/** Enable file logging */
enableFileLogging: boolean;
/** Log file path */
logFilePath?: string;
/** Minimum level to log */
minLevel: ErrorLevel;
/** Maximum log file size (bytes) */
maxFileSize: number;
/** Number of log files to retain */
maxFiles: number;
/** Enable console logging */
enableConsoleLogging: boolean;
/** Include stack traces */
includeStackTraces: boolean;
/** Enable structured JSON logging */
structuredLogging: boolean;
/** Log rotation enabled */
enableRotation: boolean;
}
/**
* Error statistics for reporting
*/
export interface ErrorStatistics {
/** Total errors by level */
byLevel: Record<ErrorLevel, number>;
/** Total errors by category */
byCategory: Record<ErrorCategory, number>;
/** Error trends over time */
timeline: Array<{
timestamp: string;
level: ErrorLevel;
category: ErrorCategory;
count: number;
}>;
/** Most frequent errors */
frequentErrors: Array<{
message: string;
count: number;
level: ErrorLevel;
category: ErrorCategory;
}>;
/** Recovery statistics */
recovery: {
totalAttempts: number;
successfulRecoveries: number;
recoveryRate: number;
};
}
/**
* Comprehensive error logging and technical issue reporting system
*/
export declare class ErrorLogger {
private config;
private errors;
private technicalIssues;
private sessionId;
private startTime;
private static readonly LEVEL_PRIORITIES;
constructor(config?: Partial<ErrorLoggerConfig>);
/**
* Log an error entry
*/
logError(level: ErrorLevel, category: ErrorCategory, message: string, details?: {
error?: Error;
url?: string;
source?: string;
context?: Record<string, any>;
recoveryAction?: string;
recovered?: boolean;
}): string;
/**
* Log debug information
*/
debug(message: string, source?: string, context?: Record<string, any>): string;
/**
* Log informational message
*/
info(message: string, source?: string, context?: Record<string, any>): string;
/**
* Log warning
*/
warn(message: string, category?: ErrorCategory, source?: string, context?: Record<string, any>): string;
/**
* Log error
*/
error(message: string, category?: ErrorCategory, error?: Error, source?: string, context?: Record<string, any>): string;
/**
* Log fatal error
*/
fatal(message: string, category?: ErrorCategory, error?: Error, source?: string, context?: Record<string, any>): string;
/**
* Log browser-specific errors
*/
logBrowserError(message: string, error?: Error, url?: string, recoveryAction?: string): string;
/**
* Log network errors
*/
logNetworkError(message: string, url: string, error?: Error, responseCode?: number): string;
/**
* Log scanning errors
*/
logScanningError(message: string, url: string, error?: Error, scanPhase?: string): string;
/**
* Log crawling errors
*/
logCrawlingError(message: string, url: string, error?: Error, depth?: number): string;
/**
* Log timeout errors with recovery information
*/
logTimeoutError(message: string, url: string, timeout: number, recoveryAction?: string): string;
/**
* Report a technical issue
*/
reportTechnicalIssue(type: TechnicalIssue['type'], severity: TechnicalIssue['severity'], title: string, description: string, affectedUrls: string[], technicalDetails: Record<string, any>, suggestedFixes?: string[]): string;
/**
* Collect system diagnostics
*/
collectSystemDiagnostics(): Promise<SystemDiagnostics>;
/**
* Generate error statistics
*/
getErrorStatistics(): ErrorStatistics;
/**
* Get all errors for reporting
*/
getErrors(level?: ErrorLevel, category?: ErrorCategory): ErrorEntry[];
/**
* Get all technical issues
*/
getTechnicalIssues(): TechnicalIssue[];
/**
* Export error log to file
*/
exportErrorLog(filePath: string, format?: 'json' | 'csv' | 'txt'): void;
/**
* Clear all logged errors
*/
clear(): void;
/**
* Get session information
*/
getSessionInfo(): {
id: string;
startTime: Date;
errorCount: number;
issueCount: number;
};
/**
* Private helper methods
*/
private initializeLogging;
private shouldLogLevel;
private writeToFile;
private logToConsole;
private analyzeForTechnicalIssues;
private formatTextLogLine;
private checkLogRotation;
private exportToCsv;
private exportToText;
private generateSessionId;
private generateErrorId;
private generateIssueId;
/**
* Static utility methods
*/
/**
* Create a default error logger
*/
static createDefault(): ErrorLogger;
/**
* Create a console-only error logger
*/
static createConsoleOnly(): ErrorLogger;
/**
* Create a file-only error logger
*/
static createFileOnly(logFilePath: string): ErrorLogger;
/**
* Create a debug-level error logger
*/
static createDebug(): ErrorLogger;
}
//# sourceMappingURL=error-logger.d.ts.map