规范并补充日志内容

This commit is contained in:
2026-01-16 14:30:42 +08:00
parent 4e0bb33ce2
commit fd6a82eb4e
28 changed files with 325 additions and 537 deletions

View File

@@ -1,4 +1,6 @@
using System.Net.NetworkInformation;
using Ayay.SerilogLogs;
using Serilog;
using System.Net.NetworkInformation;
using System.Net.Sockets;
namespace SHH.CameraSdk;
@@ -13,6 +15,8 @@ public class CameraCoordinator
{
#region --- (Private Resources & Configurations) ---
private static ILogger _sysLog = Log.ForContext("SourceContext", LogModules.Core);
/// <summary> 已注册的相机设备集合(线程安全,支持并发添加与遍历) </summary>
private readonly ConcurrentBag<BaseVideoSource> _cameras = new();
@@ -90,7 +94,7 @@ public class CameraCoordinator
catch (Exception ex)
{
// 捕获调度层全局异常,避免循环终止
Console.WriteLine($"[CoordinatorCritical] 调度循环异常: {ex.Message}");
_sysLog.Error($"[Coordinator] 调度循环异常: {ex.Message}");
}
try
@@ -186,7 +190,7 @@ public class CameraCoordinator
// 【关键修复】:增加了 && cam.IsRunning 判定,防止待机状态下被误复位
else if (isPhysicalOk && cam.IsOnline && !isFlowing && cam.IsRunning) // [cite: 504]
{
Console.WriteLine($"[自愈] 设备 {cam.Id} 僵死({secondsSinceLastFrame:F1}秒无帧),复位中...");
_sysLog.Warning($"[Coordinator] [自愈] 设备 {cam.Id} 僵死({secondsSinceLastFrame:F1}秒无帧),复位中...");
await cam.StopAsync().ConfigureAwait(false);
}
}