From ddd6889459bccf5015cd0c9629cdf4f4ce8fb8e1 Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期一, 04 五月 2026 11:26:25 +0800
Subject: [PATCH] 优化Win+D隐藏的问题
---
src/Moli.Desktop/Diagnostics/DiagnosticsService.cs | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/Moli.Desktop/Diagnostics/DiagnosticsService.cs b/src/Moli.Desktop/Diagnostics/DiagnosticsService.cs
index f1e6b58..093219d 100644
--- a/src/Moli.Desktop/Diagnostics/DiagnosticsService.cs
+++ b/src/Moli.Desktop/Diagnostics/DiagnosticsService.cs
@@ -33,13 +33,13 @@
Properties = properties ?? new Dictionary<string, string>()
};
+ _logger.Log(MapLevel(severity), "{Code}: {Message}", code, message);
lock (_gate)
{
_entries.Add(entry);
+ AppendLog(entry);
}
- _logger.Log(MapLevel(severity), "{Code}: {Message}", code, message);
- AppendLog(entry);
return entry;
}
@@ -59,7 +59,18 @@
line += " " + string.Join(";", entry.Properties.Select(p => $"{p.Key}={p.Value}"));
}
- File.AppendAllText(_logFile, line + Environment.NewLine, Encoding.UTF8);
+ try
+ {
+ File.AppendAllText(_logFile, line + Environment.NewLine, Encoding.UTF8);
+ }
+ catch (IOException)
+ {
+ _logger.LogWarning("Failed to append diagnostic log file because it is currently unavailable.");
+ }
+ catch (UnauthorizedAccessException)
+ {
+ _logger.LogWarning("Failed to append diagnostic log file because access was denied.");
+ }
}
private static LogLevel MapLevel(DiagnosticSeverity severity) => severity switch
--
Gitblit v1.9.1