@re-shell/cli
Version:
Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja
131 lines (130 loc) • 3.69 kB
TypeScript
import { EventEmitter } from 'events';
export interface ErrorContext {
id: string;
timestamp: Date;
command: string;
args: Record<string, any>;
options: Record<string, any>;
error: Error;
stack: string;
environment: EnvironmentInfo;
context: Record<string, any>;
breadcrumbs: Breadcrumb[];
tags: Record<string, string>;
level: ErrorLevel;
}
export interface EnvironmentInfo {
platform: string;
arch: string;
nodeVersion: string;
cliVersion: string;
cwd: string;
memory: {
rss: number;
heapTotal: number;
heapUsed: number;
external: number;
};
timing: {
uptime: number;
processUptime: number;
};
}
export interface Breadcrumb {
timestamp: Date;
message: string;
category: string;
level: BreadcrumbLevel;
data?: Record<string, any>;
}
export declare enum ErrorLevel {
DEBUG = 0,
INFO = 1,
WARNING = 2,
ERROR = 3,
FATAL = 4
}
export declare enum BreadcrumbLevel {
DEBUG = 0,
INFO = 1,
WARNING = 2,
ERROR = 3
}
export interface ErrorContextOptions {
maxBreadcrumbs?: number;
maxContextSize?: number;
enableStackTrace?: boolean;
enableEnvironment?: boolean;
enableMemoryInfo?: boolean;
enableFileContext?: boolean;
storageDir?: string;
autoCapture?: boolean;
}
export declare class ErrorContextManager extends EventEmitter {
private breadcrumbs;
private context;
private tags;
private maxBreadcrumbs;
private maxContextSize;
private enableStackTrace;
private enableEnvironment;
private enableMemoryInfo;
private enableFileContext;
private storageDir;
private autoCapture;
constructor(options?: ErrorContextOptions);
private setupAutoCapture;
captureException(error: Error, context: {
command: string;
args: Record<string, any>;
options: Record<string, any>;
level?: ErrorLevel;
context?: Record<string, any>;
tags?: Record<string, string>;
}): string;
private generateErrorId;
private captureStackTrace;
private captureEnvironment;
private getCliVersion;
private storeErrorContext;
private cleanupOldErrors;
addBreadcrumb(breadcrumb: Omit<Breadcrumb, 'timestamp'>): void;
setContext(key: string, value: any): void;
removeContext(key: string): void;
getContext(): Record<string, any>;
setTag(key: string, value: string): void;
removeTag(key: string): void;
getTags(): Record<string, string>;
getBreadcrumbs(): Breadcrumb[];
clearBreadcrumbs(): void;
clearContext(): void;
clearTags(): void;
clear(): void;
getErrorContext(errorId: string): ErrorContext | null;
getAllErrorContexts(): ErrorContext[];
deleteErrorContext(errorId: string): boolean;
getRecentErrors(count?: number): ErrorContext[];
searchErrors(query: {
command?: string;
level?: ErrorLevel;
tag?: string;
dateFrom?: Date;
dateTo?: Date;
}): ErrorContext[];
generateReport(): {
summary: {
totalErrors: number;
errorsByLevel: Record<string, number>;
errorsByCommand: Record<string, number>;
recentErrors: number;
};
trends: {
last24Hours: number;
last7Days: number;
last30Days: number;
};
};
}
export declare function createErrorContextManager(options?: ErrorContextOptions): ErrorContextManager;
export declare function getGlobalErrorContext(): ErrorContextManager;
export declare function setGlobalErrorContext(manager: ErrorContextManager): void;