modify log

This commit is contained in:
lnk
2026-01-23 16:10:51 +08:00
parent 3e05e627d3
commit 529abd4d55
4 changed files with 49 additions and 39 deletions

View File

@@ -566,7 +566,7 @@ void init_config() {
std::cout << "this is multiple process of index:" << g_front_seg_index << std::endl;
if(g_front_seg_index > g_front_seg_num){
DIY_ERRORLOG_CODE("process",0,LOG_CODE_CONFIG,"进程号应该为1到配置的最大进程号范围内的整数,退出当前进程");
DIY_ERRORLOG_CODE("process",0,LOG_CODE_CONFIG,"进程号参数异常,当前进程退出");
exit(-1039);
}
@@ -576,22 +576,10 @@ void init_config() {
std::cout << "this is single process" << std::endl;
}
else{
DIY_ERRORLOG_CODE("process",0,LOG_CODE_CONFIG,"进程号应该为1到配置的最大进程号范围内的整数,退出当前进程");
DIY_ERRORLOG_CODE("process",0,LOG_CODE_CONFIG,"进程号参数异常,当前进程退出");
exit(-1039);
}
//测试进程端口
/*if (g_node_id == STAT_DATA_BASE_NODE_ID)//统计采集
TEST_PORT = TEST_PORT + STAT_DATA_BASE_NODE_ID + g_front_seg_index;
else if (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID) {//补召
TEST_PORT = TEST_PORT + RECALL_HIS_DATA_BASE_NODE_ID + g_front_seg_index;
}
else if (g_node_id == THREE_SECS_DATA_BASE_NODE_ID) {//3秒采集
TEST_PORT = TEST_PORT + THREE_SECS_DATA_BASE_NODE_ID + g_front_seg_index;
}
else if (g_node_id == SOE_COMTRADE_BASE_NODE_ID) {//暂态录波
TEST_PORT = TEST_PORT + SOE_COMTRADE_BASE_NODE_ID + g_front_seg_index;
}*/
//测试端口处理
TEST_PORT = TEST_PORT + g_front_seg_index;
}
@@ -1232,23 +1220,20 @@ int recall_json_handle_from_mq(const std::string& body)
} catch (const std::exception& e) {
std::cerr << "Error parsing JSON: " << e.what() << std::endl;
// ★与原逻辑等价:无法解析,不再进入 recall_json_handle
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"主题:%s - tag:%s的补招触发消息失败",
G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"无法解析补招信息,补招触发失败");
return 10004;
}
// 提取 "messageBody"(字符串)
if (!root.contains("messageBody") || !root["messageBody"].is_string()) {
std::cerr << "'messageBody' is missing or is not a string" << std::endl;
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"主题:%s - tag:%s的补招触发消息失败",
G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"无法解析补招信息,补招触发失败");
return 10004;
}
std::string messageBodyStr = root["messageBody"].get<std::string>();
if (messageBodyStr.empty()) {
std::cerr << "'messageBody' is empty" << std::endl;
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"主题:%s - tag:%s的补招触发消息失败",
G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"无法解析补招信息,补招触发失败");
return 10004;
}
@@ -1258,8 +1243,7 @@ int recall_json_handle_from_mq(const std::string& body)
mb = nlohmann::json::parse(messageBodyStr);
} catch (const std::exception& e) {
std::cerr << "Failed to parse 'messageBody' JSON: " << e.what() << std::endl;
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"主题:%s - tag:%s的补招触发消息失败",
G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"无法解析补招信息,补招触发失败");
return 10004;
}