mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 09:50:40 +08:00
feat: Wpf日志文件输出分级
This commit is contained in:
@@ -126,14 +126,30 @@ public partial class CopilotViewModel : Screen
|
||||
/// <param name="color">The font color.</param>
|
||||
/// <param name="weight">The font weight.</param>
|
||||
/// <param name="showTime">Whether show time.</param>
|
||||
public void AddLog(string content, string color = UiLogColor.Trace, string weight = "Regular", bool showTime = true)
|
||||
public void AddLog(string? content, string color = UiLogColor.Trace, string weight = "Regular", bool showTime = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
LogItemViewModels.Add(new LogItemViewModel(content, color, weight, "HH':'mm':'ss", showTime: showTime));
|
||||
if (showTime)
|
||||
{
|
||||
_logger.Information(content);
|
||||
switch (color)
|
||||
{
|
||||
case UiLogColor.Error:
|
||||
_logger.Error("{Content}", content);
|
||||
break;
|
||||
case UiLogColor.Warning:
|
||||
_logger.Warning("{Content}", content);
|
||||
break;
|
||||
default:
|
||||
_logger.Information("{Content}", content);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -884,13 +884,29 @@ public class TaskQueueViewModel : Screen
|
||||
/// <param name="color">The font color.</param>
|
||||
/// <param name="weight">The font weight.</param>
|
||||
/// <param name="toolTip">The toolTip</param>
|
||||
public void AddLog(string content, string color = UiLogColor.Trace, string weight = "Regular", ToolTip? toolTip = null)
|
||||
public void AddLog(string? content, string color = UiLogColor.Trace, string weight = "Regular", ToolTip? toolTip = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(content))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
var log = new LogItemViewModel(content, color, weight, toolTip: toolTip);
|
||||
LogItemViewModels.Add(log);
|
||||
_logger.Information("{Content}", content);
|
||||
switch (color)
|
||||
{
|
||||
case UiLogColor.Error:
|
||||
_logger.Error("{Content}", content);
|
||||
break;
|
||||
case UiLogColor.Warning:
|
||||
_logger.Warning("{Content}", content);
|
||||
break;
|
||||
default:
|
||||
_logger.Information("{Content}", content);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user