规范并补充日志内容

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,7 @@
namespace SHH.CameraSdk;
using Ayay.SerilogLogs;
using Serilog;
namespace SHH.CameraSdk;
/// <summary>
/// 全局流分发器(静态类 | 线程安全)
@@ -14,6 +17,8 @@ public static class GlobalStreamDispatcher
{
#region --- 1. (Predefined Subscription Channels) ---
private static ILogger _sysLog = Log.ForContext("SourceContext", LogModules.Core);
/// <summary>
/// UI 预览订阅通道:供 UI 模块订阅帧数据,用于实时画面显示
/// 回调参数:(设备唯一标识, 处理后的智能帧数据)
@@ -50,7 +55,7 @@ public static class GlobalStreamDispatcher
}
catch (Exception ex)
{
Console.WriteLine($"[GlobalBus Error] 广播异常: {ex.Message}");
_sysLog.Error($"[GlobalBus] 广播分发异常: {ex.Message}");
}
// B. 执行你原有的定向分发逻辑 (给处理链用)
@@ -151,7 +156,7 @@ public static class GlobalStreamDispatcher
if (deviceMap.TryRemove(specificDeviceId, out _))
{
// 可选:如果该 AppId 下没设备了,是否清理外层字典?(为了性能通常不清理,或者定期清理)
// Console.WriteLine($"[Dispatcher] {appId} 已停止订阅设备 {specificDeviceId}");
_sysLog.Information($"[Dispatcher] {appId} 已停止订阅设备 ID:{specificDeviceId }");
}
}
}
@@ -223,7 +228,7 @@ public static class GlobalStreamDispatcher
{
// 单个订阅者异常隔离,不影响其他分发流程
task.Context.AddLog($"帧任务 [Seq:{sequence}] 投递到 AppId:{appId} 失败:{ex.Message}");
Console.WriteLine($"[DispatchError] AppId={appId}, DeviceId={deviceId}, Error={ex.Message}");
_sysLog.Error($"[Dispatch] AppId={appId}, DeviceId={deviceId}, Error={ex.Message}");
}
}
@@ -242,7 +247,7 @@ public static class GlobalStreamDispatcher
}
catch (Exception ex)
{
Console.WriteLine($"[DispatchError] DeviceSpecific AppId={appId}, Dev={deviceId}: {ex.Message}");
_sysLog.Error($"[Dispatch] DeviceSpecific AppId={appId}, Dev={deviceId}: {ex.Message}");
}
}
}
@@ -285,7 +290,7 @@ public static class GlobalStreamDispatcher
}
catch (Exception ex)
{
Console.WriteLine($"[SidecarDispatchError] App={sidecarAppId}, Dev={deviceId}: {ex.Message}");
_sysLog.Error($"[Dispatch] App={sidecarAppId}, Dev={deviceId}: {ex.Message}");
}
}
}
@@ -317,7 +322,7 @@ public static class GlobalStreamDispatcher
// TryRemove 是原子的、线程安全的
if (_routingTable.TryRemove(appId, out _))
{
Console.WriteLine($"[Dispatcher] 已强制移除 AppId [{appId}] 的所有订阅路由");
_sysLog.Error($"[Dispatcher] 已强制移除 AppId [{appId}] 的所有订阅路由.");
}
}