fix log realdata send funtion

This commit is contained in:
lnk
2025-02-26 16:39:10 +08:00
parent c597ee5b9b
commit f167d705a9
9 changed files with 126 additions and 38 deletions

View File

@@ -118,9 +118,16 @@ extern std::string G_MQCONSUMER_KEY_RC;//key
extern std::string G_MQCONSUMER_TOPIC_SET;//topie_recall
extern std::string G_MQCONSUMER_TAG_SET;//tag
extern std::string G_MQCONSUMER_KEY_SET;//key
extern std::string G_MQCONSUMER_TOPIC_LOGSET;//topie_log
extern std::string G_MQCONSUMER_TAG_LOGSET;//tag
extern std::string G_MQCONSUMER_KEY_LOGSET;//key
extern std::string G_MQCONSUMER_TOPIC_LOG;//topie_log
extern std::string G_MQCONSUMER_TAG_LOG;//tag
extern std::string G_MQCONSUMER_KEY_LOG;//key
extern std::string G_LOG_TOPIC;//topie
extern std::string G_LOG_TAG;//tag
extern std::string G_LOG_KEY;//key
extern pthread_mutex_t errorListMutex;
extern pthread_mutex_t warnListMutex;
extern pthread_mutex_t normalListMutex;
#define APRTIME_8H (28800000000ULL)
#define APRTIME_1H (3600000000ULL)
@@ -587,18 +594,48 @@ void KafkaSendThread::run()
//lnk20250225<32><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
Ckafka_data_t log_send;
log_send.strTopic
log_send.strTopic = QString::fromStdString(G_LOG_TOPIC);
bool log_gotten;
log_gotten = false;
pthread_mutex_lock(&targetMutex);
if (!kafka_data_list.isEmpty()) {
data_gotten = true;
log_send = kafka_data_list.takeFirst();
}
kafka_data_list_mutex.unlock();
if (log_gotten && ) {
if (normalOutputEnabled) {
// <20><><EFBFBD><EFBFBD> normalOutputEnabled Ϊ 1<><31><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD> normalList <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> normalList <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_lock(&normalListMutex);
if (!normalList.empty()) {
data_gotten = true;
log_send.strText = QString::fromStdString(normalList.front());
normalList.pop_front();
}
pthread_mutex_unlock(&normalListMutex);
} else if (warnOutputEnabled) {
// <20><><EFBFBD><EFBFBD> normalOutputEnabled Ϊ 0<><30><EFBFBD><EFBFBD> warnOutputEnabled Ϊ 1<><31><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD> warnList <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> warnList <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_lock(&warnListMutex);
if (!warnList.empty()) {
data_gotten = true;
log_send.strText = QString::fromStdString(warnList.front());
warnList.pop_front();
}
pthread_mutex_unlock(&warnListMutex);
} else if (errorOutputEnabled) {
// <20><><EFBFBD><EFBFBD> normalOutputEnabled <20><> warnOutputEnabled <20><>Ϊ 0<><30><EFBFBD><EFBFBD> errorOutputEnabled Ϊ 1<><31>ȡ errorList <20><><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> errorList <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_lock(&errorListMutex);
if (!errorList.empty()) {
data_gotten = true;
log_send.strText = QString::fromStdString(errorList.front());
errorList.pop_front();
}
pthread_mutex_unlock(&errorListMutex);
}
if (log_gotten) {
static uint32_t count = 0;
printf("BEGIN current log send no.%i -------->>>>>>>>>>>> %s \n", count,
QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toAscii().data());
my_rocketmq_send(log_send);
}
/*if (data_gotten) {
LD_info_t* LD_info = find_LD_info_only_from_mp_id(data.mp_id.toAscii().data());
@@ -1374,7 +1411,7 @@ int StringToInt(const std::string& str) {
}
// <20><><EFBFBD><EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
void parse_log(const std::string& json_str, const std::string& output_dir) {
void parse_log(const std::string& json_str) {
// <20><><EFBFBD><EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
cJSON* root = cJSON_Parse(json_str.c_str());
if (root == nullptr) {
@@ -1453,37 +1490,37 @@ void parse_log(const std::string& json_str, const std::string& output_dir) {
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(frontType == subdir){
if(fun == "open"){
if (code_str == "ERROR"){
if (level == "ERROR"){
// <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
redirectErrorOutput(true);
}
else if (code_str == "WARN"){
else if (level == "WARN"){
// <20><><EFBFBD>ø澯<C3B8><E6BEAF><EFBFBD><EFBFBD>
redirectWarnOutput(true);
}
else if (code_str == "NORMAL"){
else if (level == "NORMAL"){
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
redirectNormalOutput(true);
}
else{
std::cout << "code_str error" <<std::endl;
std::cout << "level error" <<std::endl;
}
}
else{
if (code_str == "ERROR"){
if (level == "ERROR"){
// <20>رմ<D8B1><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
redirectErrorOutput(false);
}
else if (code_str == "WARN"){
else if (level == "WARN"){
// <20><><EFBFBD>ø澯<C3B8><E6BEAF><EFBFBD><EFBFBD>
redirectWarnOutput(false);
}
else if (code_str == "NORMAL"){
else if (level == "NORMAL"){
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
redirectNormalOutput(false);
}
else{
std::cout << "code_str error" <<std::endl;
std::cout << "level error" <<std::endl;
}
}
}
@@ -1493,6 +1530,7 @@ void parse_log(const std::string& json_str, const std::string& output_dir) {
}
std::cout << "this msg should only execute once" <<std::endl;
}
}
// <20>ͷ<EFBFBD> JSON <20><><EFBFBD><EFBFBD>
cJSON_Delete(root);