Skip to content

Commit 98bee99

Browse files
committed
refactor: stores crash logs into crashes sub-folder and removes the User line in crash log
Signed-off-by: leo <longshuang@msn.cn>
1 parent 5b06432 commit 98bee99

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/App.axaml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ public static void LogException(Exception ex)
8383
if (ex == null)
8484
return;
8585

86+
var crashDir = Path.Combine(Native.OS.DataDir, "crashes");
87+
if (!Directory.Exists(crashDir))
88+
Directory.CreateDirectory(crashDir);
89+
8690
var time = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
87-
var file = Path.Combine(Native.OS.DataDir, $"crash_{time}.log");
91+
var file = Path.Combine(crashDir, $"{time}.log");
8892
using var writer = new StreamWriter(file);
8993
writer.WriteLine($"Crash::: {ex.GetType().FullName}: {ex.Message}");
9094
writer.WriteLine();
@@ -94,7 +98,6 @@ public static void LogException(Exception ex)
9498
writer.WriteLine($"Framework: {AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}");
9599
writer.WriteLine($"Source: {ex.Source}");
96100
writer.WriteLine($"Thread Name: {Thread.CurrentThread.Name ?? "Unnamed"}");
97-
writer.WriteLine($"User: {Environment.UserName}");
98101
writer.WriteLine($"App Start Time: {Process.GetCurrentProcess().StartTime}");
99102
writer.WriteLine($"Exception Time: {DateTime.Now}");
100103
writer.WriteLine($"Memory Usage: {Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024} MB");

0 commit comments

Comments
 (0)