增加日志

This commit is contained in:
2026-01-16 07:23:56 +08:00
parent 2754cdff15
commit 4e0bb33ce2
11 changed files with 104 additions and 59 deletions

View File

@@ -1,4 +1,6 @@
using OpenCvSharp;
using Ayay.SerilogLogs;
using OpenCvSharp;
using Serilog;
using SHH.CameraSdk.HikFeatures;
using System.Runtime.ExceptionServices;
using System.Security;
@@ -17,6 +19,8 @@ public class HikVideoSource : BaseVideoSource,
{
#region --- (Global Resources) ---
// 日志实例
private static ILogger _sdkLog = Log.ForContext("SourceContext", LogModules.HikVisionSdk);
// 静态路由表
private static readonly ConcurrentDictionary<int, HikVideoSource> _instances = new();
// 全局异常回调
@@ -103,14 +107,18 @@ public class HikVideoSource : BaseVideoSource,
if (currentEpoch != _connectionEpoch) return;
if (!HikSdkManager.Initialize())
throw new CameraException(CameraErrorCode.SdkNotInitialized, "SDK初始化失败", DeviceBrand.HikVision);
{
_sdkLog.Error("HikVision Sdk 初始化失败.");
throw new CameraException(CameraErrorCode.SdkNotInitialized, "HikVision Sdk 初始化失败.", DeviceBrand.HikVision);
}
try
{
HikNativeMethods.NET_DVR_SetExceptionCallBack_V30(0, IntPtr.Zero, _globalExceptionCallback, IntPtr.Zero);
// [审计] 记录登录动作
AddAuditLog($"正在执行物理登录... ({_config.IpAddress})");
AddAuditLog($"Hik 正在执行登录 => ID:{_config.Id} IP:{_config.IpAddress} Port:{_config.Port} Name:{_config.Name}");
_sdkLog.Information($"Hik 正在执行登录 => ID:{_config.Id} IP:{_config.IpAddress} Port:{_config.Port} Name:{_config.Name}");
var devInfo = new HikNativeMethods.NET_DEVICEINFO_V30();
int newUserId = HikNativeMethods.NET_DVR_Login_V30(