|
@@ -30,10 +30,10 @@ RvcLogSdkManager::RvcLogSdkManager() {
|
|
|
|
|
|
bool RvcLogSdkManager::wait_for_counter_greater_than_one_with_timeout() {
|
|
|
std::unique_lock<std::mutex> lock(m_mutex);
|
|
|
- // 等待条件满足(即 counter > 1),最多等待 100 毫秒
|
|
|
+ // 锟饺达拷锟斤拷锟斤拷锟斤拷锟姐(锟斤拷 counter > 1锟斤拷锟斤拷锟斤拷锟饺达拷 100 锟斤拷锟斤拷
|
|
|
bool timed_out = !condition_variable.wait_for(lock, std::chrono::milliseconds(100), [&] { return m_logFlush_num > 0; });
|
|
|
|
|
|
- m_logFlush_num = 0;//已经刷新了,后续重新计数
|
|
|
+ m_logFlush_num = 0;//锟窖撅拷刷锟斤拷锟剿o拷锟斤拷锟斤拷锟斤拷锟铰硷拷锟斤拷
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -71,23 +71,23 @@ int RvcLogSdkManager::SendTestLog_loki(const char* app, const char* env, const c
|
|
|
{//http://99.12.23.49:3100/loki/api/v1/push
|
|
|
if (m_testLogMode == false)
|
|
|
return -1;
|
|
|
- // 1. 构造Loki兼容的JSON请求体
|
|
|
+ // 1. 锟斤拷锟斤拷Loki锟斤拷锟捷碉拷JSON锟斤拷锟斤拷锟斤拷
|
|
|
Json::Value root;
|
|
|
Json::Value stream;
|
|
|
Json::Value values(Json::arrayValue);
|
|
|
|
|
|
- // 设置标签
|
|
|
+ // 锟斤拷锟矫憋拷签
|
|
|
stream["app"] = app;
|
|
|
stream["env"] = env;
|
|
|
|
|
|
- // 设置日志内容和时间戳(当前时间戳,纳秒级)
|
|
|
+ // 锟斤拷锟斤拷锟斤拷志锟斤拷锟捷猴拷时锟斤拷锟斤拷锟斤拷锟角笆憋拷锟斤拷锟斤拷锟斤拷锟诫级锟斤拷
|
|
|
Json::Value logEntry(Json::arrayValue);
|
|
|
logEntry.append(std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(
|
|
|
std::chrono::system_clock::now().time_since_epoch()).count()));
|
|
|
logEntry.append(body);
|
|
|
values.append(logEntry);
|
|
|
|
|
|
- // 组装完整请求
|
|
|
+ // 锟斤拷装锟斤拷锟斤拷锟斤拷锟斤拷
|
|
|
Json::Value streams(Json::arrayValue);
|
|
|
Json::Value streamObj;
|
|
|
streamObj["stream"] = stream;
|
|
@@ -110,14 +110,12 @@ int RvcLogSdkManager::SendTestLog_loki(const char* app, const char* env, const c
|
|
|
client.Do(&sendErr, &curResult, NULL);//Test Logs
|
|
|
};
|
|
|
|
|
|
- std::thread(send_loki, jsonReq).detach();//必须得用线程,猜测为外部变量析构或这
|
|
|
+ std::thread(send_loki, jsonReq).detach();//锟斤拷锟斤拷锟斤拷锟斤拷叱蹋锟斤拷虏锟轿�拷獠匡拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|