规范并补充日志内容

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

@@ -38,8 +38,8 @@ public static class Bootstrapper
"--uris", "localhost,9001,command,调试PC;",
// 日志中心配置 (格式: IP,Port,Desc)
"--sequris", "58.216.225.5,20026,日志处置中心;",
"--seqkey", "Shine101173874928;",
"--sequris", "172.16.41.241,20026,日志处置中心;",
"--seqkey", "Shine899195994250;",
// 端口策略
"--mode", "1",
@@ -100,11 +100,11 @@ public static class Bootstrapper
// =========================================================
if (exitCode != 0)
{
sysLog.Fatal($"💀 [程序终止] {reason} (Code: {exitCode})");
sysLog.Fatal($"[Core] 💀 [程序终止] {reason} (Code: {exitCode})");
}
else
{
sysLog.Information($"👋 [程序退出] {reason}");
sysLog.Information($"[Core] 👋 [程序退出] {reason}");
}
// =========================================================
@@ -113,7 +113,7 @@ public static class Bootstrapper
// 防止 SDK 句柄残留导致下次启动无法连接相机
try
{
sysLog.Information("正在清理 Hikvision SDK 资源...");
sysLog.Information("[Core] 正在清理 Hikvision SDK 资源...");
// 如果你的项目中引用了 SDK请务必解开这行注释
HikNativeMethods.NET_DVR_Cleanup();
@@ -162,7 +162,7 @@ public static class Bootstrapper
/// </summary>
public static int ScanForAvailablePort(ServiceConfig config, ILogger logger)
{
logger.Information($"🔍 开始端口检测: 起始={config.BasePort}, 范围={config.MaxPortRange}");
logger.Information($"[Core] 🔍 开始端口检测: 起始={config.BasePort}, 范围={config.MaxPortRange}");
for (int i = 0; i <= config.MaxPortRange; i++)
{
@@ -171,15 +171,15 @@ public static class Bootstrapper
{
if (currentPort != config.BasePort)
{
logger.Warning($"⚙️ 端口自动漂移: {config.BasePort} -> {currentPort}");
logger.Warning($"[Core] ⚙️ 端口自动漂移: {config.BasePort} -> {currentPort}");
}
else
{
logger.Information($"✅ 端口检测通过: {currentPort}");
logger.Information($"[Core] ✅ 端口检测通过: {currentPort}");
}
return currentPort;
}
logger.Debug($"⚠️ 端口 {currentPort} 被占用,尝试下一个...");
logger.Debug($"[Core] ⚠️ 端口 {currentPort} 被占用,尝试下一个...");
}
return -1;
}
@@ -217,16 +217,16 @@ public static class Bootstrapper
/// </summary>
public static void WarmUpHardware(ILogger logger)
{
logger.Information("Hik Sdk 开始预热.");
logger.Information("[Core] Hik Sdk 开始预热.");
try
{
HikNativeMethods.NET_DVR_Init();
HikSdkManager.ForceWarmUp();
logger.Information("💡Hik Sdk 预热成功.");
logger.Information("[Core] 💡Hik Sdk 预热成功.");
}
catch (Exception ex)
{
logger.Error(ex, "⚠️ Hik Sdk 预热失败.");
logger.Error(ex, "[Core] ⚠️ Hik Sdk 预热失败.");
}
}
@@ -244,13 +244,13 @@ public static class Bootstrapper
try
{
// 将 tcp:// 转换为 http:// 以适配 gRPC
// 将 tcp:// 转换为 http:// 以适配 gRpc
string targetUrl = config.CommandEndpoints.First().Uri.Replace("tcp://", "http://");
using var channel = GrpcChannel.ForAddress(targetUrl);
var client = new GatewayProvider.GatewayProviderClient(channel);
gRpcLog.Information($"[gRPC] 正在执行预注册: {targetUrl}");
gRpcLog.Information($"[gRpc] 正在执行预注册: {targetUrl}");
var resp = await client.RegisterInstanceAsync(new RegisterRequest
{
InstanceId = config.AppId,
@@ -261,11 +261,11 @@ public static class Bootstrapper
ProcessId = Environment.ProcessId,
Description = ""
});
gRpcLog.Information($"💡[gRPC] 预注册成功: {resp.Message}");
gRpcLog.Information($"[gRpc] 💡预注册成功: {resp.Message}");
}
catch (Exception ex)
{
gRpcLog.Error($"⚠️ [gRPC] 预注册尝试失败: {ex.Message}");
gRpcLog.Error($"[gRpc] ⚠️ 预注册尝试失败: {ex.Message}");
}
}