Logger.StackTrace
This commit is contained in:
1 parent
d3daf1988f
commit
c18fef7074
3 files changed
+9
-2
No files matched your search
@@ -77,6 +77,12 @@ public static class Logger {
|
|||||||
public static void SendToDebug(Exception ex, string? message = null, LogLevel level = LogLevel.Error, [CallerFilePath] string filePath = "")
|
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)}");
|
=> Debug.WriteLine($"{BaseLogger.GetLogPrefix(level, filePath)}{(message is null ? "" : $"{message}:")}{ex.GetDisplay(true)}");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 记录当前堆栈信息。
|
||||||
|
/// </summary>
|
||||||
|
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 内插优化
|
#region 内插优化
|
||||||
|
|
||||||
// VB.NET:由于不兼容 InterpolatedStringHandler,只能手动使用 Lambda
|
// VB.NET:由于不兼容 InterpolatedStringHandler,只能手动使用 Lambda
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ public abstract class RedoableWorkerBase<TOut>(Func<CancellationToken?, Progress
|
|||||||
Succeeded?.Invoke();
|
Succeeded?.Invoke();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (!ex.IsCanceled())
|
if (!ex.IsCanceled())
|
||||||
Logger.Log(ex, $"{creatorMemberName}:运行失败{(pendingRedo ? ",但即将重启,或可忽略" : "")}", pendingRedo ? LogLevel.Info : LogLevel.Warn);
|
Logger.Log(ex, $"{creatorMemberName}:运行失败{(pendingRedo ? ",但即将重启,或可忽略" : "")}",
|
||||||
|
pendingRedo ? LogLevel.Warn : LogLevel.Error, LogBehavior.ToastIfDebug);
|
||||||
lock (this) {
|
lock (this) {
|
||||||
realCts?.Dispose();
|
realCts?.Dispose();
|
||||||
if (pendingRedo) { // 接取重启请求
|
if (pendingRedo) { // 接取重启请求
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
|
|
||||||
namespace MeloongCore;
|
namespace MeloongCore;
|
||||||
public static class SystemUtils {
|
public static class WindowsUtils {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前程序是否拥有管理员权限。
|
/// 当前程序是否拥有管理员权限。
|
||||||
Reference in new issue
Block a user