modify log format
This commit is contained in:
@@ -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("process","【ERROR】前置当前进程的进程号为:%d,前置的多进程最大进程号为:%d,当前进程的进程号应该为1到最大进程号范围内的整数,退出该进程",g_front_seg_index,g_front_seg_num);
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_CONFIG,"进程号应该为1到配置的最大进程号范围内的整数,退出当前进程");
|
||||
exit(-1039);
|
||||
}
|
||||
|
||||
@@ -576,7 +576,7 @@ void init_config() {
|
||||
std::cout << "this is single process" << std::endl;
|
||||
}
|
||||
else{
|
||||
DIY_ERRORLOG("process","【ERROR】前置当前进程的进程号为:%d,前置的多进程最大进程号为:%d,应该为大于0的整数,退出该进程",g_front_seg_index,g_front_seg_num);
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_CONFIG,"进程号应该为1到配置的最大进程号范围内的整数,退出当前进程");
|
||||
exit(-1039);
|
||||
}
|
||||
|
||||
@@ -811,7 +811,6 @@ int parse_3s_xml(trigger_3s_xml_t* trigger_3s_xml) {
|
||||
}
|
||||
|
||||
std::cout << "/etc/trigger3s/*.xml success..." << std::endl;
|
||||
DIY_WARNLOG("process", "【WARN】前置读取实时数据触发文件成功,即将注册实时数据报告");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -882,7 +881,7 @@ int parse_recall_xml(recall_xml_t* recall_xml, const std::string& id) {
|
||||
|
||||
DIR* dir = opendir(cfg_dir.c_str());
|
||||
if (!dir) {
|
||||
DIY_ERRORLOG("process", "【ERROR】前置的%d号进程 无法解析补招文件,补招文件路径FRONT_PATH + /etc/recall/不存在", g_front_seg_index);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -894,7 +893,7 @@ int parse_recall_xml(recall_xml_t* recall_xml, const std::string& id) {
|
||||
std::string filepath = cfg_dir + "/" + filename;
|
||||
tinyxml2::XMLDocument doc;
|
||||
if (doc.LoadFile(filepath.c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
DIY_ERRORLOG("process", "【ERROR】前置的%d号进程 无法解析补招文件%s,补招内容无效", g_front_seg_index, filepath.c_str());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -988,7 +987,7 @@ void DeletcRecallXml() {
|
||||
DIR* dir = opendir(cfg_dir.c_str());
|
||||
if (!dir) {
|
||||
std::cerr << "folder does not exist!" << std::endl;
|
||||
DIY_ERRORLOG("process", "【ERROR】前置的%d号进程 删除旧的补招文件失败,补招文件路径FRONT_PATH + /etc/recall/不存在", g_front_seg_index);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1007,7 +1006,7 @@ void DeletcRecallXml() {
|
||||
if (stat(fullpath.c_str(), &file_stat) == 0) {
|
||||
if (file_stat.st_mtime < cutoff) {
|
||||
if (remove(fullpath.c_str()) == 0) {
|
||||
DIY_INFOLOG("process", "【NORMAL】前置的%d号进程 删除超过两天的补招文件", g_front_seg_index);
|
||||
|
||||
} else {
|
||||
std::cerr << "Failed to remove file: " << fullpath << std::endl;
|
||||
}
|
||||
@@ -1029,7 +1028,7 @@ void CreateRecallXml() {
|
||||
g_StatisticLackList_list_mutex.lock();
|
||||
|
||||
if (!g_StatisticLackList.empty()) {
|
||||
DIY_INFOLOG("process", "【NORMAL】前置的%d号进程 开始写入补招文件", g_front_seg_index);
|
||||
|
||||
|
||||
std::map<std::string, std::list<JournalRecall>> id_map;
|
||||
for (const auto& jr : g_StatisticLackList) {
|
||||
@@ -1069,7 +1068,7 @@ void CreateRecallXml() {
|
||||
|
||||
tinyxml2::XMLError save_result = doc.SaveFile(path.str().c_str());
|
||||
if (save_result != tinyxml2::XML_SUCCESS) {
|
||||
DIY_ERRORLOG("process", "【ERROR】前置的%d号进程 无法将补招文件写入路径: %s", g_front_seg_index, path.str().c_str());
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1233,23 +1232,22 @@ 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("process","【ERROR】前置的%d号进程处理topic:%s_%s的补招触发消息失败,消息的json结构不正确",
|
||||
g_front_seg_index, G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"主题:%s - tag:%s的补招触发消息失败",G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
|
||||
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("process","【ERROR】前置的%d号进程处理topic:%s_%s的补招触发消息失败,没有messageBody字段",
|
||||
g_front_seg_index, G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"主题:%s - tag:%s的补招触发消息失败",
|
||||
G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
|
||||
return 10004;
|
||||
}
|
||||
std::string messageBodyStr = root["messageBody"].get<std::string>();
|
||||
if (messageBodyStr.empty()) {
|
||||
std::cerr << "'messageBody' is empty" << std::endl;
|
||||
DIY_ERRORLOG("process","【ERROR】前置的%d号进程处理topic:%s_%s的补招触发消息失败,messageBody为空",
|
||||
g_front_seg_index, G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"主题:%s - tag:%s的补招触发消息失败",
|
||||
G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
|
||||
return 10004;
|
||||
}
|
||||
|
||||
@@ -1259,8 +1257,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("process","【ERROR】前置的%d号进程处理topic:%s_%s的补招触发消息失败,messageBody的json结构不正确",
|
||||
g_front_seg_index, G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_JSON,"主题:%s - tag:%s的补招触发消息失败",G_MQCONSUMER_TOPIC_RC.c_str(), FRONT_INST.c_str());
|
||||
return 10004;
|
||||
}
|
||||
|
||||
@@ -1780,14 +1777,14 @@ int parse_ledger_update_xml(trigger_update_xml_t& trigger_update_xml)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
if (!load_ledger_update_from_xml(trigger_update_xml, filename)) {
|
||||
DIY_WARNLOG("process", "【WARN】成功读取台账更新文件: %s", filename.c_str());
|
||||
|
||||
}
|
||||
|
||||
if (std::remove(filename.c_str()) != 0) {
|
||||
DIY_ERRORLOG("process", "【ERROR】删除台账更新文件失败: %s", filename.c_str());
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
DIY_INFOLOG("process", "【NORMAL】成功删除台账更新文件: %s", filename.c_str());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5815,7 +5812,7 @@ void on_device_response_minimal(int response_code,
|
||||
<< " rc=" << response_code << " recall_status=" << front.recall_status << std::endl; //错误响应码
|
||||
|
||||
//记录日志
|
||||
DIY_ERRORLOG_CODE(matched_monitor->monitor_id.c_str(),2,static_cast<int>(LogCode::LOG_CODE_RECALL),"【ERROR】监测点:%s 补招数据失败 - 失败时间点:%s 至 %s",matched_monitor->monitor_id.c_str(),front.StartTime.c_str(),front.EndTime.c_str());
|
||||
DIY_ERRORLOG_CODE(matched_monitor->monitor_id.c_str(),2,static_cast<int>(LogCode::LOG_CODE_RECALL),"监测点:%s 补招数据失败 - 失败时间点:%s 至 %s",matched_monitor->monitor_id.c_str(),front.StartTime.c_str(),front.EndTime.c_str());
|
||||
}
|
||||
else { //补招失败
|
||||
front.recall_status = static_cast<int>(RecallStatus::FAILED);
|
||||
@@ -5825,7 +5822,7 @@ void on_device_response_minimal(int response_code,
|
||||
<< " rc=" << response_code << " recall_status=" << front.recall_status<< std::endl; //错误响应码
|
||||
|
||||
//记录日志
|
||||
DIY_ERRORLOG_CODE(matched_monitor->monitor_id.c_str(),2,static_cast<int>(LogCode::LOG_CODE_RECALL),"【ERROR】监测点:%s 补招数据失败 - 失败时间点:%s 至 %s",matched_monitor->monitor_id.c_str(),front.StartTime.c_str(),front.EndTime.c_str());
|
||||
DIY_ERRORLOG_CODE(matched_monitor->monitor_id.c_str(),2,static_cast<int>(LogCode::LOG_CODE_RECALL),"监测点:%s 补招数据失败 - 失败时间点:%s 至 %s",matched_monitor->monitor_id.c_str(),front.StartTime.c_str(),front.EndTime.c_str());
|
||||
}
|
||||
updated = true;
|
||||
} else { //首条不是 RUNNING 状态,不应该收到这条响应
|
||||
|
||||
Reference in New Issue
Block a user