From ce8e09b1ff7b54ba0199de84c739c15dc00e7649 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Sun, 1 Dec 2024 02:26:44 -0600 Subject: [PATCH] Flush orphaned logs, handle readonly folder (#523) --- RetroBar/Utilities/ManagedShellLogger.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/RetroBar/Utilities/ManagedShellLogger.cs b/RetroBar/Utilities/ManagedShellLogger.cs index 617324b6..41b94b04 100644 --- a/RetroBar/Utilities/ManagedShellLogger.cs +++ b/RetroBar/Utilities/ManagedShellLogger.cs @@ -39,17 +39,24 @@ private void SetupLogging() SetupFileLog(); - ShellLogger.Attach(new ConsoleLog()); + ShellLogger.Attach(new ConsoleLog(), true); } private void SetupFileLog() { DeleteOldLogFiles(); - _fileLog = new FileLog(Path.Combine(_logPath, $"{_logName}.{_logExt}")); - _fileLog?.Open(); + try + { + _fileLog = new FileLog(Path.Combine(_logPath, $"{_logName}.{_logExt}")); + _fileLog?.Open(); - ShellLogger.Attach(_fileLog); + ShellLogger.Attach(_fileLog); + } + catch (Exception ex) + { + ShellLogger.Error($"Unable to open and attach file logger: {ex.Message}"); + } } private void DeleteOldLogFiles()