using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Extensions.Logging; namespace ThreadPilot.Services { /// /// Enhanced logging service interface for persistent, structured logging /// public interface IEnhancedLoggingService { /// /// Gets the current log file path /// string CurrentLogFilePath { get; } /// /// Gets the log directory path /// string LogDirectoryPath { get; } /// /// Gets whether debug logging is enabled /// bool IsDebugLoggingEnabled { get; } /// /// Event raised when a critical error occurs /// event EventHandler? CriticalErrorOccurred; /// /// Initialize the logging service /// Task InitializeAsync(); /// /// Log a power plan change event /// Task LogPowerPlanChangeAsync(string fromPlan, string toPlan, string reason, string? processName = null); /// /// Log a process monitoring event /// Task LogProcessMonitoringEventAsync(string eventType, string processName, int processId, string details); /// /// Log a game boost event /// Task LogGameBoostEventAsync(string eventType, string gameName, string details); /// /// Log a user action /// Task LogUserActionAsync(string action, string details, string? context = null); /// /// Log a system event /// Task LogSystemEventAsync(string eventType, string message, LogLevel level = LogLevel.Information); /// /// Log an error with structured data /// Task LogErrorAsync(Exception exception, string context, Dictionary? additionalData = null); /// /// Log application startup/shutdown events /// Task LogApplicationLifecycleEventAsync(string eventType, string details); /// /// Get recent log entries /// Task> GetRecentLogEntriesAsync(int count = 100); /// /// Begin a correlated operation scope for better debugging /// IDisposable BeginScope(string operationName, object? parameters = null); /// /// Get the current correlation ID /// string? GetCurrentCorrelationId(); /// /// Get log entries for a specific date range /// Task> GetLogEntriesAsync(DateTime fromDate, DateTime toDate); /// /// Clean up old log files based on retention policy /// Task CleanupOldLogsAsync(); /// /// Get log file statistics /// Task GetLogStatisticsAsync(); /// /// Export logs to a file /// Task ExportLogsAsync(DateTime fromDate, DateTime toDate, string? exportPath = null); /// /// Update logging configuration /// Task UpdateConfigurationAsync(bool enableDebugLogging, int maxFileSizeMb, int retentionDays); } /// /// Event args for critical errors /// public class CriticalErrorEventArgs : EventArgs { public Exception Exception { get; } public string Context { get; } public DateTime Timestamp { get; } public Dictionary AdditionalData { get; } public CriticalErrorEventArgs(Exception exception, string context, Dictionary? additionalData = null) { Exception = exception; Context = context; Timestamp = DateTime.UtcNow; AdditionalData = additionalData ?? new Dictionary(); } } /// /// Represents a log entry /// public class LogEntry { public DateTime Timestamp { get; set; } public LogLevel Level { get; set; } public string Category { get; set; } = string.Empty; public string Message { get; set; } = string.Empty; public string? Exception { get; set; } public Dictionary Properties { get; set; } = new(); public string? CorrelationId { get; set; } } /// /// Log file statistics /// public class LogFileStatistics { public long CurrentFileSizeBytes { get; set; } public int TotalLogFiles { get; set; } public long TotalLogSizeBytes { get; set; } public DateTime OldestLogDate { get; set; } public DateTime NewestLogDate { get; set; } public int ErrorCount { get; set; } public int WarningCount { get; set; } public int InfoCount { get; set; } } }