规范并补充日志内容
This commit is contained in:
@@ -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}] 的所有订阅路由.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace SHH.CameraSdk;
|
||||
using Ayay.SerilogLogs;
|
||||
using Serilog;
|
||||
|
||||
namespace SHH.CameraSdk;
|
||||
|
||||
/// <summary>
|
||||
/// 帧处理管道(后台处理核心)
|
||||
@@ -12,6 +15,8 @@ public class ProcessingPipeline
|
||||
{
|
||||
#region --- 私有资源与状态 (Private Resources & States) ---
|
||||
|
||||
private static ILogger _sysLog = Log.ForContext("SourceContext", LogModules.Core);
|
||||
|
||||
/// <summary> 任务队列(有界通道):存储待处理的帧任务 </summary>
|
||||
private readonly Channel<ProcessingTask> _queue;
|
||||
|
||||
@@ -135,7 +140,7 @@ public class ProcessingPipeline
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 捕获处理过程中的异常,避免影响后续任务执行
|
||||
Console.WriteLine($"[PipelineError] 帧处理失败 (DeviceId: {task.DeviceId}, Seq: {task.Decision.Sequence}): {ex.Message}");
|
||||
_sysLog.Error($"[Pipeline] 帧处理失败 (DeviceId: {task.DeviceId}, Seq: {task.Decision.Sequence}): {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user