Browse Source

Add debug print

qiuyang 2 months ago
parent
commit
51b8333115

+ 2 - 2
CMakeLists.txt

@@ -12,11 +12,11 @@ add_compile_options(-DRELEASE)
 
 # --[ Options
 option(build_modules "build modules" ON)
-option(build_source "build source programs" OFF)
+option(build_source "build source programs" ON)
 option(build_plugins "build plugins programs" ON)
 option(build_test "build test programs" ON)
 
-add_subdirectory(framework)
+add_subdirectory(framework)   
 if(build_modules)
   add_subdirectory(modules)
 endif()

BIN
lib/libgsd_modules.so


BIN
lib/libgsd_plugins.so


+ 29 - 5
modules/Hepu/src/Hepu.cpp

@@ -11,6 +11,9 @@ namespace gsd{
     }
 
     int32_t Hepu::Init(std::string username, std::string url, int port){
+        cout<<"Hepu username: "<<username<<endl;
+        cout<<"Hepu api url: "<<url<<endl;
+        cout<<"Hepu port: "<<port<<endl;
         this->username_ = username;
         m_hepu = std::make_shared<httplib::Client>(url, port);
         if(m_hepu == NULL){
@@ -48,19 +51,24 @@ namespace gsd{
         hepuloginMsg.objectToJson(msg);
         msg += "\r\n";
 
-        //cout<<msg<<endl;
+        cout<<"login json msg: "<<endl;
+        cout<<msg<<endl;
 
         if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
+            cout<<res->body<<endl;
             if(res->status != 100){
                 HepuLoginRe hepuloginReMsg;
                 if(!hepuloginReMsg.jsonToObject(res->body)){
+                    cout<<"login res json2object fail."<<endl;
                     return ERR;
                 }
                 if(hepuloginReMsg.ackvalue != 100){
+                    cout<<"login res ack err: "<<hepuloginReMsg.ackvalue<<endl;
                     return ERR;
                 }
                 if(hepuloginReMsg.token.size()){
                     this->token_ = hepuloginReMsg.token;
+                    cout<<"login res token: "<<hepuloginReMsg.token<<endl;
                     return OK;
                 }
                 return ERR;
@@ -68,6 +76,7 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
+            cout<<"The Hepu is not avaliable, "<<err<<endl;
             ErrorL << "The service is not available,"<<err<<endl;
             return ERR;
         }
@@ -86,15 +95,19 @@ namespace gsd{
         hepuHBMsg.objectToJson(msg);
         msg+="\r\n";
         
-        //cout<<msg<<endl;
+        cout<<"hb json msg: "<<endl;
+        cout<<msg<<endl;
 
         if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
+            cout<<res->body<<endl;
             if(res->status != 100){
                 HepuHBRe hepuHBReMsg;
                 if(!hepuHBReMsg.jsonToObject(res->body)){
+                    cout<<"hb res json2object fail."<<endl;
                     return ERR;
                 }
                 if(hepuHBReMsg.ackvalue != 100){
+                    cout<<"hb res ack err: "<<hepuHBReMsg.ackvalue<<endl;
                     return ERR;
                 }
                 return OK;
@@ -102,6 +115,7 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
+            cout<<"Hepu heartbeat failed,"<<err<<endl;
             ErrorL << "Hepu Heartbeat failed,"<<err<<endl;
             return ERR;
         }
@@ -117,15 +131,19 @@ namespace gsd{
         hepuHBMsg.objectToJson(msg);
         msg+="\r\n";
         
-        //cout<<msg<<endl;
+        cout<<"hb json msg: "<<endl;
+        cout<<msg<<endl;
 
         if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
+            cout<<res->body<<endl;
             if(res->status != 100){
                 HepuHBRe hepuHBReMsg;
                 if(!hepuHBReMsg.jsonToObject(res->body)){
+                    cout<<"hb res json2object fail."<<endl;
                     return ERR;
                 }
                 if(hepuHBReMsg.ackvalue != 100){
+                    cout<<"hb res ack err: "<<hepuHBReMsg.ackvalue<<endl;
                     return ERR;
                 }
                 return OK;
@@ -133,6 +151,7 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
+            cout<<"Hepu heartbeat failed,"<<err<<endl;
             ErrorL << "Hepu Heartbeat failed,"<<err<<endl;
             return ERR;
         }
@@ -150,15 +169,19 @@ namespace gsd{
         HepuTargetMsg.objectToJson(msg);
         msg+="\r\n";
         
-        //cout<<msg<<endl;
+        cout<<"Target json msg: "<<endl;
+        cout<<msg<<endl;
 
         if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
+            cout<<res->body<<endl;
             if(res->status != 100){
                 HepuTargetRe hepuTargetReMsg;
                 if(!hepuTargetReMsg.jsonToObject(res->body)){
+                    cout<<"target res json2object fail."<<endl;
                     return ERR;
                 }
                 if(hepuTargetReMsg.ackvalue != 100){
+                    cout<<"hb res ack err: "<<hepuTargetReMsg.ackvalue<<endl;
                     return ERR;
                 }
                 return OK;
@@ -166,7 +189,8 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
-            ErrorL << "Hepu Heartbeat failed,"<<err<<endl;
+            cout<<"Hepu send target failed,"<<err<<endl;
+            ErrorL << "Hepu send target failed,"<<err<<endl;
             return ERR;
         }
         return ERR;

+ 3 - 2
plugins/HepuPlugin/src/HepuPlugin.cpp

@@ -18,12 +18,13 @@ namespace gsd
         this->m_hepuClient->setUsr(config::getPtr()->HepuUsr);
         this->m_hepuClient->setPort(config::getPtr()->HepuPort);
         if(this->m_hepuClient->Init(config::getPtr()->HepuUsr , config::getPtr()->HepuIP, config::getPtr()->HepuPort) == OK){
-            InfoL << "Hepu IPC http login succeeds."<<endl;
+            cout<<"Hepu IPC http login success."<<endl;
+            InfoL << "Hepu IPC http login success."<<endl;
         }else{
+            cout<<"Hepu IPC http login failed."<<endl;
             WarnL << "Hepu IPC http login failed."<<endl;
         }
 
-        cout<<"Assign pool"<<endl;
         if(this->pool == nullptr){
             this->pool = std::make_shared<ThreadPool>(1,ThreadPool::PRIORITY_NORMAL,false);
         }

+ 4 - 9
source/CMakeLists.txt

@@ -71,7 +71,7 @@ include_directories(${CNSTREAM_ROOT_DIR}/modules/InfineFilter/include)
 include_directories(${CNSTREAM_ROOT_DIR}/modules/Monitor/include)
 include_directories(${CNSTREAM_ROOT_DIR}/modules/TCPClient/include)
 include_directories(${CNSTREAM_ROOT_DIR}/modules/config/include)
-#include_directories(${CNSTREAM_ROOT_DIR}/modules/Hepu/include)
+include_directories(${CNSTREAM_ROOT_DIR}/modules/Hepu/include)
 include_directories(${CNSTREAM_ROOT_DIR}/source/UserApp/include)
 #include_directories(${CNSTREAM_ROOT_DIR}/source/TestApp/include)
 include_directories(${CNSTREAM_ROOT_DIR}/framework/core/include)
@@ -82,18 +82,13 @@ include_directories(${CNSTREAM_ROOT_DIR}/plugins/HttpPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/MonitorPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/TcpPlugin/include)
 include_directories(${CNSTREAM_ROOT_DIR}/plugins/AuditPlugin/include)
-#include_directories(${CNSTREAM_ROOT_DIR}/plugins/HepuPlugin/include)
+include_directories(${CNSTREAM_ROOT_DIR}/plugins/HepuPlugin/include)
 
 aux_source_directory(${CNSTREAM_ROOT_DIR}/source/src srcs)
-#aux_source_directory(${CNSTREAM_ROOT_DIR}/source/test tests)
 aux_source_directory(${CNSTREAM_ROOT_DIR}/source/UserApp/src userApps)
-#aux_source_directory(${CNSTREAM_ROOT_DIR}/source/TestApp/src testApps)
 
 # ---[ add targets
-# set(EXECUTABLE_OUTPUT_PATH ${SOURCE_ROOT_DIR}/bin)
+set(EXECUTABLE_OUTPUT_PATH ${SOURCE_ROOT_DIR}/bin)
 
 add_executable(gsd ${srcs} ${userApps} ${3RDPARTY_LIBS})
-target_link_libraries(gsd gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)
-
-#add_executable(hepu_test ${tests} ${testApps} ${3RDPARTY_LIBS})
-#target_link_libraries(hepu_test gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)
+target_link_libraries(gsd gsd_core gsd_modules gsd_plugins ${3RDPARTY_LIBS} pthread dl)

BIN
source/bin/gsd


BIN
source/bin/main