codecrucible-synth
Version:
Production-Ready AI Development Platform with Multi-Voice Synthesis, Smithery MCP Integration, Enterprise Security, and Zero-Timeout Reliability
121 lines • 3.21 kB
TypeScript
/**
* Enterprise Structured Logging System
* Implements correlation IDs, structured JSON logs, and multiple transport layers
*/
export interface LogEntry {
timestamp: string;
level: string;
message: string;
service: string;
version: string;
correlationId: string;
traceId?: string;
spanId?: string;
userId?: string;
sessionId?: string;
operation?: string;
duration?: number;
statusCode?: number;
error?: {
name: string;
message: string;
stack: string;
code?: string;
};
metadata: Record<string, any>;
}
export interface LogConfig {
level: string;
format: 'json' | 'text';
environment: string;
service: string;
version: string;
outputs: {
console: boolean;
file: boolean;
remote?: {
endpoint: string;
apiKey: string;
};
};
rotation: {
enabled: boolean;
maxSize: string;
maxFiles: number;
};
}
export declare class StructuredLogger {
private logger;
private config;
private service;
private version;
constructor(config: LogConfig);
/**
* Create Winston format with structured logging
*/
private createFormat;
/**
* Create Winston transports based on configuration
*/
private createTransports;
/**
* Parse size string to bytes
*/
private parseSize;
/**
* Get or generate correlation ID
*/
private getCorrelationId;
/**
* Set correlation ID for async context
*/
setCorrelationId(id: string): void;
/**
* Generate new correlation ID
*/
generateCorrelationId(): string;
/**
* Run function with correlation ID context
*/
withCorrelationId<T>(id: string, fn: () => T): T;
/**
* Structured logging methods
*/
info(message: string, metadata?: Record<string, any>): void;
warn(message: string, metadata?: Record<string, any>): void;
error(message: string, error?: Error, metadata?: Record<string, any>): void;
debug(message: string, metadata?: Record<string, any>): void;
/**
* Operation-specific logging with timing
*/
logOperation<T>(operation: string, fn: () => Promise<T>, metadata?: Record<string, any>): Promise<T>;
/**
* HTTP request logging
*/
logHttpRequest(req: any, res: any, duration: number): void;
/**
* Security event logging
*/
logSecurityEvent(event: string, metadata?: Record<string, any>): void;
/**
* Performance metrics logging
*/
logPerformanceMetric(metric: string, value: number, unit: string, metadata?: Record<string, any>): void;
/**
* Business event logging
*/
logBusinessEvent(event: string, metadata?: Record<string, any>): void;
/**
* Express middleware for request logging
*/
middleware(): (req: any, res: any, next: any) => void;
/**
* Child logger with additional context
*/
child(metadata: Record<string, any>): StructuredLogger;
/**
* Flush logs (useful for graceful shutdown)
*/
flush(): Promise<void>;
}
//# sourceMappingURL=structured-logger.d.ts.map