codecrucible-synth
Version:
Production-Ready AI Development Platform with Multi-Voice Synthesis, Smithery MCP Integration, Enterprise Security, and Zero-Timeout Reliability
235 lines • 6.77 kB
TypeScript
/**
* Advanced Logging System with Structured Format and Levels
*
* Provides comprehensive logging with structured data, multiple outputs,
* log aggregation, security logging, and performance monitoring.
*/
export declare enum LogLevel {
TRACE = 0,
DEBUG = 1,
INFO = 2,
WARN = 3,
ERROR = 4,
FATAL = 5
}
export declare enum LogCategory {
SYSTEM = "system",
SECURITY = "security",
PERFORMANCE = "performance",
AGENT = "agent",
TOOL = "tool",
MCP = "mcp",
USER = "user",
MODEL = "model",
FILE_SYSTEM = "file_system",
NETWORK = "network",
API = "api",
ERROR = "error",
AUDIT = "audit"
}
export interface StructuredLogEntry {
timestamp: string;
level: LogLevel;
category: LogCategory;
message: string;
context?: Record<string, any>;
metadata?: {
requestId?: string;
userId?: string;
sessionId?: string;
source?: string;
component?: string;
operation?: string;
duration?: number;
tags?: string[];
};
error?: {
name: string;
message: string;
stack?: string;
code?: string | number;
};
sensitive?: boolean;
correlationId?: string;
}
export interface AdvancedLoggerConfig {
level: LogLevel;
categories: LogCategory[];
outputs: LogOutput[];
retention: {
maxFiles: number;
maxAge: number;
maxSize: number;
};
security: {
enableSecurityLogging: boolean;
enableAuditLogging: boolean;
maskSensitiveData: boolean;
sensitiveFields: string[];
};
performance: {
enablePerformanceLogging: boolean;
slowOperationThreshold: number;
enableMemoryTracking: boolean;
};
correlation: {
enableCorrelation: boolean;
correlationIdHeader: string;
};
}
export interface LogOutput {
type: 'console' | 'file' | 'remote' | 'database';
config: any;
formatter?: LogFormatter;
filter?: LogFilter;
}
export interface LogFormatter {
format(entry: StructuredLogEntry): string;
}
export interface LogFilter {
shouldLog(entry: StructuredLogEntry): boolean;
}
export interface PerformanceMetrics {
operation: string;
duration: number;
memory: {
used: number;
total: number;
external: number;
};
timestamp: string;
context?: Record<string, any>;
}
/**
* Advanced Structured Logger
*/
export declare class AdvancedLogger {
private config;
private logQueue;
private isProcessing;
private correlationCounter;
private performanceMetrics;
private activeOperations;
constructor(config?: Partial<AdvancedLoggerConfig>);
/**
* Log with structured data
*/
log(level: LogLevel, category: LogCategory, message: string, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata'], error?: Error): void;
/**
* Trace level logging (most verbose)
*/
trace(category: LogCategory, message: string, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata']): void;
/**
* Debug level logging
*/
debug(category: LogCategory, message: string, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata']): void;
/**
* Info level logging
*/
info(category: LogCategory, message: string, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata']): void;
/**
* Warning level logging
*/
warn(category: LogCategory, message: string, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata']): void;
/**
* Error level logging
*/
error(category: LogCategory, message: string, error?: Error, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata']): void;
/**
* Fatal level logging (highest severity)
*/
fatal(category: LogCategory, message: string, error?: Error, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata']): void;
/**
* Security-specific logging
*/
security(message: string, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata']): void;
/**
* Audit logging for compliance
*/
audit(message: string, context?: Record<string, any>, metadata?: StructuredLogEntry['metadata']): void;
/**
* Performance logging
*/
performance(operation: string, duration: number, context?: Record<string, any>): void;
/**
* Start performance tracking for an operation
*/
startOperation(operationId: string, context?: any): void;
/**
* End performance tracking and log results
*/
endOperation(operationId: string, additionalContext?: any): void;
/**
* Create a child logger with additional context
*/
child(context: Record<string, any>): AdvancedLogger;
/**
* Get performance statistics
*/
getPerformanceStats(): {
totalOperations: number;
averageDuration: number;
slowOperations: number;
memoryUsage: any;
recentMetrics: PerformanceMetrics[];
};
/**
* Clear performance metrics
*/
clearPerformanceMetrics(): void;
/**
* Flush all pending logs
*/
flush(): Promise<void>;
/**
* Update configuration
*/
updateConfig(config: Partial<AdvancedLoggerConfig>): void;
private shouldLog;
private sanitizeContext;
private maskSensitiveField;
private detectSensitiveData;
private serializeError;
private generateCorrelationId;
private getMemoryUsage;
private enqueueLog;
private processLogQueue;
private processOutput;
private outputToConsole;
private outputToFile;
private outputToRemote;
private defaultConsoleFormat;
private getColoredLevel;
private manageLogRetention;
}
/**
* Console formatter for human-readable output
*/
export declare class ConsoleFormatter implements LogFormatter {
format(entry: StructuredLogEntry): string;
private getColoredLevel;
}
/**
* JSON formatter for structured output
*/
export declare class JSONFormatter implements LogFormatter {
format(entry: StructuredLogEntry): string;
}
/**
* Level-based filter
*/
export declare class LevelFilter implements LogFilter {
private minLevel;
constructor(minLevel: LogLevel);
shouldLog(entry: StructuredLogEntry): boolean;
}
/**
* Category-based filter
*/
export declare class CategoryFilter implements LogFilter {
private allowedCategories;
constructor(allowedCategories: LogCategory[]);
shouldLog(entry: StructuredLogEntry): boolean;
}
export declare const advancedLogger: AdvancedLogger;
//# sourceMappingURL=advanced-logging-system.d.ts.map