feat: 日志组件添加等级筛选
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
|
||||
@if (_driverBaseItem != null && _driverBaseItem?.CurrentDevice != null && _driverBaseItem.CurrentDevice.Channel.LogEnable == true)
|
||||
{
|
||||
<LogConsole LogPath=@_driverBaseItem.LogPath HeaderText="@Localizer["LogConsole"]" HeightText="var(--logconsle-height)"></LogConsole>
|
||||
<LogConsole Logger=@_driverBaseItem.LogMessage LogPath=@_driverBaseItem.LogPath HeaderText="@Localizer["LogConsole"]" HeightText="var(--logconsle-height)"></LogConsole>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class AdapterDebugBase : ComponentBase, IDisposable
|
||||
var data = await Plc.ReadAsync(RegisterAddress, ArrayLength, DataType);
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Plc.Logger?.Debug(data.Content.ToJsonNetString());
|
||||
Plc.Logger?.LogInformation(data.Content.ToJsonNetString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -99,7 +99,7 @@ public abstract class AdapterDebugBase : ComponentBase, IDisposable
|
||||
var data = await Plc.WriteAsync(RegisterAddress, WriteValue.GetJTokenFromString(), DataType);
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Plc.Logger?.Debug($" {WriteValue.GetJTokenFromString()} {Localizer["WriteSuccess"]}");
|
||||
Plc.Logger?.LogInformation($" {WriteValue.GetJTokenFromString()} {Localizer["WriteSuccess"]}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -106,7 +106,10 @@
|
||||
|
||||
</div>
|
||||
<div class="col-12 col-md-7 ">
|
||||
<LogConsole LogPath=@LogPath HeaderText=@HeaderText></LogConsole>
|
||||
@if (Plc!=null)
|
||||
{
|
||||
<LogConsole Logger=@Plc.Logger LogPath=@LogPath HeaderText=@HeaderText></LogConsole>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
<HeaderTemplate>
|
||||
<div class="flex-fill">
|
||||
</div>
|
||||
@if (Logger!=null)
|
||||
{
|
||||
<Select @bind-Value="@Logger.LogLevel" IsPopover></Select>
|
||||
}
|
||||
<Button Color="Color.None" style="color: var(--bs-card-title-color);" Icon=@(IsPause?"fa fa-play":"fa fa-pause") OnClick="Pause" />
|
||||
<Button IsAsync Color="Color.None" style="color: var(--bs-card-title-color);" Icon=@("fa fa-sign-out") OnClick="HandleOnExportClick" />
|
||||
<Button IsAsync Color="Color.None" style="color: var(--bs-card-title-color);" Icon=@("far fa-trash-alt") OnClick="Delete" />
|
||||
|
||||
@@ -18,9 +18,10 @@ using System.Text.RegularExpressions;
|
||||
|
||||
using ThingsGateway.Core.Extension;
|
||||
using ThingsGateway.Foundation;
|
||||
using ThingsGateway.NewLife.X.Extension;
|
||||
using ThingsGateway.Razor;
|
||||
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace ThingsGateway.Debug;
|
||||
|
||||
public partial class LogConsole : IDisposable
|
||||
@@ -29,6 +30,9 @@ public partial class LogConsole : IDisposable
|
||||
|
||||
public bool Disposed { get; set; }
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public ILog Logger { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string HeaderText { get; set; } = "Log";
|
||||
|
||||
@@ -85,7 +89,7 @@ public partial class LogConsole : IDisposable
|
||||
var result = TextFileReader.LastLog(files.FirstOrDefault().FullName, 0);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
Messages = result.Content.Select(a => new LogMessage((int)a.LogLevel, $"{a.LogTime} - {a.Message}{(a.ExceptionString.IsNullOrWhiteSpace() ? null : $"{Environment.NewLine}{a.ExceptionString}")}")).ToList();
|
||||
Messages = result.Content.Where(a => a.LogLevel >= Logger?.LogLevel).Select(a => new LogMessage((int)a.LogLevel, $"{a.LogTime} - {a.Message}{(a.ExceptionString.IsNullOrWhiteSpace() ? null : $"{Environment.NewLine}{a.ExceptionString}")}")).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user