From c18fef7074bcfceb123e453d52c1ac73fb7a3400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E7=8C=AB=E8=B7=83?= <1043137532@qq.com> Date: Wed, 1 Jul 2026 06:58:01 +0800 Subject: [PATCH] Logger.StackTrace --- Shared/General/Logger.cs | 6 ++++++ Shared/General/Workers/RedoableWorker.cs | 3 ++- Wpf/Utils/{SystemUtils.cs => WindowsUtils.cs} | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) rename Wpf/Utils/{SystemUtils.cs => WindowsUtils.cs} (90%) diff --git a/Shared/General/Logger.cs b/Shared/General/Logger.cs index 140af2a..24ad3fb 100644 --- a/Shared/General/Logger.cs +++ b/Shared/General/Logger.cs @@ -77,6 +77,12 @@ public static class Logger { public static void SendToDebug(Exception ex, string? message = null, LogLevel level = LogLevel.Error, [CallerFilePath] string filePath = "") => Debug.WriteLine($"{BaseLogger.GetLogPrefix(level, filePath)}{(message is null ? "" : $"{message}:")}{ex.GetDisplay(true)}"); + /// + /// 记录当前堆栈信息。 + /// + public static void StackTrace(LogLevel level = LogLevel.Trace, [CallerFilePath] string filePath = "") + => Instance.Log(null, new StackTrace(skipFrames: 1, fNeedFileInfo: true).ToString(), level, LogBehavior.None, filePath); + #region 内插优化 // VB.NET:由于不兼容 InterpolatedStringHandler,只能手动使用 Lambda diff --git a/Shared/General/Workers/RedoableWorker.cs b/Shared/General/Workers/RedoableWorker.cs index cefdb58..042f682 100644 --- a/Shared/General/Workers/RedoableWorker.cs +++ b/Shared/General/Workers/RedoableWorker.cs @@ -132,7 +132,8 @@ public abstract class RedoableWorkerBase(Func /// 当前程序是否拥有管理员权限。