using System; using System.IO; namespace SEBPatcherUtils { public class PatchLogger { private readonly string _logFilePath; private readonly string _logModule; public PatchLogger(string logModule) { _logFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SafeExamBrowser", "SEBPatcher.log"); _logModule = logModule; } public void Log(string message, string logLevel = "INFO") { string logEntry = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} [SEBPatcher] [{_logModule}] [{logLevel}] {message}"; AppendToFile(logEntry); } public void Info(string message) { Log(message, "INFO"); } public void Error(string message) { Log(message, "ERROR"); } public void Warning(string message) { Log(message, "WARNING"); } public void Debug(string message) { Log(message, "DEBUG"); } private void AppendToFile(string logEntry) { try { File.AppendAllText(_logFilePath, logEntry + Environment.NewLine); } catch (Exception ex) { Console.WriteLine($"[SEBPatcher] Failed to write to log file: {ex.Message}"); } } } }