mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 10:50:48 +08:00
添加日志输出筛选
This commit is contained in:
@@ -14,6 +14,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
using ThingsGateway.NewLife.Log;
|
||||
using ThingsGateway.UnifyResult;
|
||||
|
||||
namespace ThingsGateway.Admin.Application;
|
||||
@@ -68,6 +69,8 @@ public class Startup : AppStartup
|
||||
|
||||
public void Use(IServiceProvider serviceProvider)
|
||||
{
|
||||
XTrace.UnhandledExceptionLogEnable = () => !App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested;
|
||||
|
||||
//检查ConfigId
|
||||
var configIdGroup = DbContext.DbConfigs.GroupBy(it => it.ConfigId);
|
||||
foreach (var configId in configIdGroup)
|
||||
|
@@ -64,6 +64,7 @@ public partial class HardwareInfoPage : IDisposable
|
||||
|
||||
private async Task<ChartDataSource> OnInit()
|
||||
{
|
||||
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested) return (new ChartDataSource());
|
||||
if (ChartDataSource == null)
|
||||
{
|
||||
var hisHardwareInfos = await HardwareJob.GetHistoryHardwareInfos();
|
||||
|
@@ -26,6 +26,7 @@ public partial class OperLogPage
|
||||
|
||||
private async Task<ChartDataSource> OnInit()
|
||||
{
|
||||
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested) return (new ChartDataSource());
|
||||
if (ChartDataSource == null)
|
||||
{
|
||||
var dayStatisticsOutputs = await SysOperateLogService.StatisticsByDayAsync(7);
|
||||
|
@@ -34,7 +34,7 @@ public static class XTrace
|
||||
|
||||
/// <summary>日志提供者,默认使用文本文件日志</summary>
|
||||
public static ILog Log { get { InitLog(); return _Log; } set { _Log = value; } }
|
||||
|
||||
public static Func<bool> UnhandledExceptionLogEnable { get; set; } = () => true;
|
||||
/// <summary>输出日志</summary>
|
||||
/// <param name="msg">信息</param>
|
||||
public static void WriteLine(String msg)
|
||||
@@ -96,6 +96,7 @@ public static class XTrace
|
||||
|
||||
private static void CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (!UnhandledExceptionLogEnable()) return;
|
||||
if (e.ExceptionObject is Exception ex)
|
||||
{
|
||||
WriteException(ex);
|
||||
@@ -110,6 +111,8 @@ public static class XTrace
|
||||
|
||||
private static void TaskScheduler_UnobservedTaskException(Object? sender, UnobservedTaskExceptionEventArgs e)
|
||||
{
|
||||
if (!UnhandledExceptionLogEnable()) return;
|
||||
|
||||
if (!e.Observed && e.Exception != null)
|
||||
{
|
||||
//WriteException(e.Exception);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginVersion>10.8.24</PluginVersion>
|
||||
<ProPluginVersion>10.8.24</ProPluginVersion>
|
||||
<PluginVersion>10.8.25</PluginVersion>
|
||||
<ProPluginVersion>10.8.25</ProPluginVersion>
|
||||
<AuthenticationVersion>2.8.4</AuthenticationVersion>
|
||||
<SourceGeneratorVersion>10.8.6</SourceGeneratorVersion>
|
||||
<NET8Version>8.0.17</NET8Version>
|
||||
|
@@ -23,6 +23,7 @@ public partial class BackendLogPage
|
||||
|
||||
private async Task<ChartDataSource> OnInit()
|
||||
{
|
||||
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested) return (new ChartDataSource());
|
||||
if (ChartDataSource == null)
|
||||
{
|
||||
var dayStatisticsOutputs = await BackendLogService.StatisticsByDayAsync(7);
|
||||
|
@@ -23,6 +23,7 @@ public partial class RpcLogPage
|
||||
|
||||
private async Task<ChartDataSource> OnInit()
|
||||
{
|
||||
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested) return (new ChartDataSource());
|
||||
if (ChartDataSource == null)
|
||||
{
|
||||
var dayStatisticsOutputs = await RpcLogService.StatisticsByDayAsync(7);
|
||||
|
@@ -86,6 +86,7 @@ public partial class GatewayIndexComponent : IDisposable
|
||||
|
||||
private Task<ChartDataSource> OnInitAlarmPie()
|
||||
{
|
||||
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested) return Task.FromResult(new ChartDataSource());
|
||||
var data = new List<bool>() { true };
|
||||
if (AlarmChartDataSource == null)
|
||||
{
|
||||
@@ -107,6 +108,7 @@ public partial class GatewayIndexComponent : IDisposable
|
||||
|
||||
private Task<ChartDataSource> OnInitBusinessDevicePie()
|
||||
{
|
||||
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested) return Task.FromResult(new ChartDataSource());
|
||||
var data = typeof(DeviceStatusEnum).ToSelectList();
|
||||
if (BusinessDeviceChartDataSource == null)
|
||||
{
|
||||
@@ -128,6 +130,7 @@ public partial class GatewayIndexComponent : IDisposable
|
||||
|
||||
private Task<ChartDataSource> OnInitCollectDevicePie()
|
||||
{
|
||||
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested) return Task.FromResult(new ChartDataSource());
|
||||
var data = typeof(DeviceStatusEnum).ToSelectList();
|
||||
if (CollectDeviceChartDataSource == null)
|
||||
{
|
||||
@@ -149,6 +152,7 @@ public partial class GatewayIndexComponent : IDisposable
|
||||
|
||||
private Task<ChartDataSource> OnInitVariablePie()
|
||||
{
|
||||
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested) return Task.FromResult(new ChartDataSource());
|
||||
var data = new List<bool>() { true, false };
|
||||
if (VariableChartDataSource == null)
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>10.8.24</Version>
|
||||
<Version>10.8.25</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user