|
|
@@ -1,5 +1,8 @@
|
|
|
#include "baseFun.h"
|
|
|
#include <time.h>
|
|
|
+#include <condition_variable>
|
|
|
+#include <RestfulFunc.h>
|
|
|
+#include "json/json.h"
|
|
|
|
|
|
long LOG_GET_TIME()
|
|
|
{
|
|
|
@@ -17,4 +20,45 @@ std::list<log_group_builder*> &RvcLogSdkManager::getResendFrameList() {
|
|
|
|
|
|
RvcLogSdkManager::RvcLogSdkManager() {
|
|
|
m_resend_frame_list.clear();
|
|
|
+ m_testLogMode = false;
|
|
|
+}
|
|
|
+
|
|
|
+bool RvcLogSdkManager::wait_for_counter_greater_than_one_with_timeout() {
|
|
|
+ std::unique_lock<std::mutex> lock(m_mutex);
|
|
|
+ // 等待条件满足(即 counter > 1),最多等待 100 毫秒
|
|
|
+ bool timed_out = !condition_variable.wait_for(lock, std::chrono::milliseconds(100), [&] { return m_logFlush_num > 0; });
|
|
|
+
|
|
|
+ m_logFlush_num = 0;//已经刷新了,后续重新计数
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+int RvcLogSdkManager::LOG_OS_TestLogPost(const char* url, const char* body)
|
|
|
+{
|
|
|
+ HttpClientResponseResult result;
|
|
|
+ HttpClientRequestConfig config(HttpRequestMethod::POST, url);
|
|
|
+
|
|
|
+ std::string str((const char*)body);
|
|
|
+ config.SetJsonBody(str.c_str());
|
|
|
+ RestfulClient client = RestfulClient::getInstance();
|
|
|
+ config.PreDo();
|
|
|
+ client.Do(&config, &result);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+int RvcLogSdkManager::SendTestLog(const char* body)
|
|
|
+{
|
|
|
+ if (m_testLogMode == false)
|
|
|
+ return -1;
|
|
|
+ HttpClientRequestConfig sendErr(HttpRequestMethod::POST, "http://99.12.43.134:9000/upload_msg");
|
|
|
+ HttpClientResponseResult curResult;
|
|
|
+ Json::Value rootReq;
|
|
|
+ Json::FastWriter writer;
|
|
|
+ rootReq["req"] = body;
|
|
|
+ rootReq["ans"] = "Json_not_vaild";
|
|
|
+ std::string jsonReq = writer.write(rootReq);
|
|
|
+ sendErr.SetJsonBody(jsonReq.c_str());
|
|
|
+ RestfulClient client = RestfulClient::getInstance();
|
|
|
+ sendErr.PreDo();
|
|
|
+ client.Do(&sendErr, &curResult);
|
|
|
+ return 0;
|
|
|
}
|