去除不必要的控制台日志输出

This commit is contained in:
Diego
2025-05-28 16:52:51 +08:00
parent ab1b364c54
commit 8e938f18be
8 changed files with 25 additions and 15 deletions

View File

@@ -29,7 +29,6 @@ using ThingsGateway.Admin.Application;
using ThingsGateway.Admin.Razor;
using ThingsGateway.Extension;
using ThingsGateway.NewLife.Caching;
using ThingsGateway.NewLife.Extension;
namespace ThingsGateway.AdminServer;
@@ -161,7 +160,8 @@ public class Startup : AppStartup
{
options.WriteFilter = (logMsg) =>
{
if (logMsg.Message.IsNullOrEmpty()) return false;
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested && logMsg.LogLevel >= LogLevel.Warning) return false;
if (string.IsNullOrEmpty(logMsg.Message)) return false;
else return true;
};

View File

@@ -71,13 +71,25 @@ public static class App
/// </summary>
public static IServiceProvider RootServices => InternalApp.RootServices;
private static IHostApplicationLifetime hostApplicationLifetime;
public static IHostApplicationLifetime HostApplicationLifetime
{
get
{
if ((hostApplicationLifetime == null))
{
hostApplicationLifetime = RootServices?.GetService<IHostApplicationLifetime>();
}
return hostApplicationLifetime;
}
}
private static IStringLocalizerFactory? stringLocalizerFactory;
/// <summary>
/// 本地化服务工厂
/// </summary>
public static IStringLocalizerFactory? StringLocalizerFactory
{
get
{

View File

@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<PluginVersion>10.6.30</PluginVersion>
<ProPluginVersion>10.6.30</ProPluginVersion>
<PluginVersion>10.6.31</PluginVersion>
<ProPluginVersion>10.6.31</ProPluginVersion>
<AuthenticationVersion>2.1.8</AuthenticationVersion>
</PropertyGroup>

View File

@@ -63,11 +63,8 @@ public partial class Synchronization : BusinessBase, IRpcDriver
protected override async ValueTask ProtectedExecuteAsync(CancellationToken cancellationToken)
{
try
{
if (_driverPropertys.IsServer)
{
if (_tcpDmtpService.ServerState != ServerState.Running)
@@ -309,11 +306,11 @@ public partial class Synchronization : BusinessBase, IRpcDriver
a.Channel.Id = CommonUtils.GetSingleId();
a.DeviceVariables.ForEach(b =>
{
b.Device.ChannelId=a.Channel.Id;
b.Device.ChannelId = a.Channel.Id;
b.Device.Id = CommonUtils.GetSingleId();
b.Variables.ForEach(c =>
{
c.DeviceId= b.Device.Id;
c.DeviceId = b.Device.Id;
c.Id = 0;
});
});

View File

@@ -37,7 +37,6 @@ using ThingsGateway.Debug;
using ThingsGateway.Extension;
using ThingsGateway.Gateway.Application;
using ThingsGateway.NewLife.Caching;
using ThingsGateway.NewLife.Extension;
namespace ThingsGateway.Server;
@@ -138,7 +137,8 @@ public class Startup : AppStartup
{
options.WriteFilter = (logMsg) =>
{
if (logMsg.Message.IsNullOrEmpty()) return false;
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested && logMsg.LogLevel >= LogLevel.Warning) return false;
if (string.IsNullOrEmpty(logMsg.Message)) return false;
else return true;
};

View File

@@ -29,7 +29,6 @@ using ThingsGateway.Admin.Application;
using ThingsGateway.Admin.Razor;
using ThingsGateway.Extension;
using ThingsGateway.NewLife.Caching;
using ThingsGateway.NewLife.Extension;
namespace ThingsGateway.Server;
@@ -162,7 +161,8 @@ public class Startup : AppStartup
{
options.WriteFilter = (logMsg) =>
{
if (logMsg.Message.IsNullOrEmpty()) return false;
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested && logMsg.LogLevel >= LogLevel.Warning) return false;
if (string.IsNullOrEmpty(logMsg.Message)) return false;
else return true;
};

View File

@@ -157,6 +157,7 @@ public class Startup : AppStartup
{
options.WriteFilter = (logMsg) =>
{
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested && logMsg.LogLevel >= LogLevel.Warning) return false;
if (string.IsNullOrEmpty(logMsg.Message)) return false;
else return true;
};

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>10.6.30</Version>
<Version>10.6.31</Version>
</PropertyGroup>
<ItemGroup>