From 0afb87c29bbbac4e69f174062025ec0242cc4190 Mon Sep 17 00:00:00 2001 From: Gayathri Buddappagari Date: Wed, 26 Jun 2019 17:50:35 +0530 Subject: [PATCH] RDKB-20643:Add OnBoarding logs --- CMakeLists.txt | 4 ++-- src/config.c | 1 + src/conn_interface.c | 2 ++ src/connection.c | 5 +++++ src/crud_internal.c | 1 + src/downstream.c | 3 +++ src/networking.c | 1 + src/nopoll_handlers.c | 2 ++ src/nopoll_helpers.c | 3 +++ src/parodus_log.h | 6 ++++++ src/partners_check.c | 1 + src/token.c | 2 ++ src/upstream.c | 1 + 13 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f43852..cf7e66c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,8 +151,8 @@ add_dependencies(libcurl curl) #------------------------------------------------------------------------------- ExternalProject_Add(cimplog PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/cimplog - GIT_REPOSITORY https://github.com/Comcast/cimplog.git - GIT_TAG "1.0.1" + GIT_REPOSITORY https://github.com/gbuddappagari/cimplog.git + GIT_TAG "cimplog_master" CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF ) add_library(libcimplog STATIC SHARED IMPORTED) diff --git a/src/config.c b/src/config.c index 38b789d..be09283 100644 --- a/src/config.c +++ b/src/config.c @@ -435,6 +435,7 @@ int parseCommandLine(int argc,char **argv,ParodusCfg * cfg) case 'r': parStrncpy(cfg->hw_last_reboot_reason, optarg,sizeof(cfg->hw_last_reboot_reason)); ParodusInfo("hw_last_reboot_reason is %s\n",cfg->hw_last_reboot_reason); + OnboardLog("Last reboot reason is %s\n",cfg->hw_last_reboot_reason); break; case 'n': diff --git a/src/conn_interface.c b/src/conn_interface.c index d8ecf0f..147463c 100644 --- a/src/conn_interface.c +++ b/src/conn_interface.c @@ -101,6 +101,7 @@ void createSocketConnection(void (* initKeypress)()) if(!create_conn_rtn) { ParodusError("Unrecovered error, terminating the process\n"); + OnboardLog("Unrecovered error, terminating the process\n"); abort(); } packMetaData(); @@ -144,6 +145,7 @@ void createSocketConnection(void (* initKeypress)()) { ParodusError("ping wait time > %d . Terminating the connection with WebPA server and retrying\n", webpa_ping_timeout_ms / 1000); ParodusInfo("Reconnect detected, setting Ping_Miss reason for Reconnect\n"); + OnboardLog("Reconnect detected, setting Ping_Miss reason for Reconnect\n"); set_global_reconnect_reason("Ping_Miss"); set_global_reconnect_status(true); set_close_retry(); diff --git a/src/connection.c b/src/connection.c index 02bae7b..1321004 100644 --- a/src/connection.c +++ b/src/connection.c @@ -393,6 +393,8 @@ int nopoll_connect (create_connection_ctx_t *ctx, int is_ipv6) if((checkHostIp(server->server_addr) == -2)) { if (check_timer_expired (&ctx->connect_timer, 15*60*1000)) { ParodusError("WebPA unable to connect due to DNS resolving to 10.0.0.1 for over 15 minutes; crashing service.\n"); + OnboardLog("WebPA unable to connect due to DNS resolving to 10.0.0.1 for over 15 minutes; crashing service.\n"); + OnboardLog("Reconnect detected, setting Dns_Res_webpa_reconnect reason for Reconnect\n"); set_global_reconnect_reason("Dns_Res_webpa_reconnect"); set_global_reconnect_status(true); @@ -448,6 +450,7 @@ int wait_connection_ready (create_connection_ctx_t *ctx) /* clear auth token in cfg so that we will refetch auth token */ memset (cfg->webpa_auth_token, 0, sizeof(cfg->webpa_auth_token)); ParodusError("Received Unauthorized response with status: %d\n", wait_status); + OnboardLog("Received Unauthorized response with status: %d\n", wait_status); return WAIT_ACTION_RETRY; } ParodusError("Client connection timeout\n"); @@ -582,10 +585,12 @@ int createNopollConnection(noPollCtx *ctx) if(conn_ctx.current_server->allow_insecure <= 0) { ParodusInfo("Connected to server over SSL\n"); + OnboardLog("Connected to server over SSL\n"); } else { ParodusInfo("Connected to server\n"); + OnboardLog("Connected to server\n"); } get_parodus_cfg()->cloud_status = CLOUD_STATUS_ONLINE; diff --git a/src/crud_internal.c b/src/crud_internal.c index 30531fc..45459d6 100644 --- a/src/crud_internal.c +++ b/src/crud_internal.c @@ -1346,6 +1346,7 @@ static int ConnDisconnectFromCloud(char *disconn_reason) if(!close_retry) { ParodusInfo("Reconnect detected, setting reason %s for Reconnect\n", disconn_reason); + OnboardLog("Reconnect detected, setting reason %s for Reconnect\n", disconn_reason); set_global_reconnect_reason(disconn_reason); set_global_reconnect_status(true); set_close_retry(); diff --git a/src/downstream.c b/src/downstream.c index 8846fd4..952a347 100644 --- a/src/downstream.c +++ b/src/downstream.c @@ -121,6 +121,9 @@ void listenerOnMessage(void * msg, size_t msgSize) ParodusInfo("Received downstream dest as :%s and transaction_uuid :%s\n", dest, ((WRP_MSG_TYPE__REQ == msgType) ? message->u.req.transaction_uuid : ((WRP_MSG_TYPE__EVENT == msgType) ? "NA" : message->u.crud.transaction_uuid))); + OnboardLog("%s\n", + ((WRP_MSG_TYPE__REQ == msgType) ? message->u.req.transaction_uuid : + ((WRP_MSG_TYPE__EVENT == msgType) ? "NA" : message->u.crud.transaction_uuid))); free(destVal); diff --git a/src/networking.c b/src/networking.c index 75ba0c6..83a4657 100644 --- a/src/networking.c +++ b/src/networking.c @@ -70,6 +70,7 @@ int checkHostIp(char * serverIP) if (retVal != 0) { ParodusError("getaddrinfo: %s\n", gai_strerror(retVal)); + OnboardLog("getaddrinfo: %s\n", gai_strerror(retVal)); } else { diff --git a/src/nopoll_handlers.c b/src/nopoll_handlers.c index 476fdc7..9a722f0 100644 --- a/src/nopoll_handlers.c +++ b/src/nopoll_handlers.c @@ -167,12 +167,14 @@ void listenerOnCloseMessage (noPollCtx * ctx, noPollConn * conn, noPollPtr user_ if( closeStatus == 1006 && !get_global_reconnect_status()) { ParodusInfo("Reconnect detected, setting default Reconnect reason %s\n",defaultReason); + OnboardLog("Reconnect detected, setting default Reconnect reason %s\n",defaultReason); set_global_reconnect_reason(defaultReason); set_global_reconnect_status(true); } else if(!get_global_reconnect_status()) { ParodusInfo("Reconnect detected, setting Reconnect reason as Unknown\n"); + OnboardLog("Reconnect detected, setting Reconnect reason as Unknown\n"); set_global_reconnect_reason("Unknown"); } diff --git a/src/nopoll_helpers.c b/src/nopoll_helpers.c index 055a3c6..524cc67 100644 --- a/src/nopoll_helpers.c +++ b/src/nopoll_helpers.c @@ -73,6 +73,7 @@ void sendMessage(noPollConn *conn, void *msg, size_t len) else { ParodusError("Failed to send msg upstream as connection is not OK\n"); + OnboardLog("Failed to send msg upstream as connection is not OK\n"); if (connErr == 0) { getCurrentTime(connStuck_startPtr); @@ -88,6 +89,7 @@ void sendMessage(noPollConn *conn, void *msg, size_t len) if( timeDiff >= (10*60*1000)) { ParodusError("conn got stuck for over 10 minutes; crashing service.\n"); + OnboardLog("conn got stuck for over 10 minutes; crashing service.\n"); kill(getpid(),SIGTERM); } @@ -149,6 +151,7 @@ void __report_log (noPollCtx * ctx, noPollDebugLevel level, const char * log_msg if (level == NOPOLL_LEVEL_CRITICAL) { ParodusError("%s\n", log_msg ); + OnboardLog("%s\n", log_msg ); } return; } diff --git a/src/parodus_log.h b/src/parodus_log.h index 2c0ec00..6b0ee7f 100644 --- a/src/parodus_log.h +++ b/src/parodus_log.h @@ -33,3 +33,9 @@ #define ParodusError(...) cimplog_error(LOGGING_MODULE, __VA_ARGS__) #define ParodusInfo(...) cimplog_info(LOGGING_MODULE, __VA_ARGS__) #define ParodusPrint(...) cimplog_debug(LOGGING_MODULE, __VA_ARGS__) +#ifdef FEATURE_SUPPORT_ONBOARD_LOGGING +#define OnboardLog(...) onboarding_log(LOGGING_MODULE, __VA_ARGS__) +#else +#define OnboardLog(...) +#endif + diff --git a/src/partners_check.c b/src/partners_check.c index 7aedcef..2c46d0c 100644 --- a/src/partners_check.c +++ b/src/partners_check.c @@ -178,6 +178,7 @@ int validate_partner_id(wrp_msg_t *msg, partners_t **partnerIds) if(matchFlag != 1) { ParodusError("Invalid partner_id %s\n",temp); + OnboardLog("Invalid partner_id %s\n",temp); if(partnersList != NULL) { for(j=0; jcount; j++) diff --git a/src/token.c b/src/token.c index 1dfc691..8926b06 100644 --- a/src/token.c +++ b/src/token.c @@ -139,6 +139,7 @@ int analyze_jwt (const cjwt_t *jwt, char **url_buf, unsigned int *port) show_times (exp_time, cur_time); if (exp_time < cur_time) { ParodusError ("JWT has expired\n"); + OnboardLog ("JWT has expired\n"); return TOKEN_ERR_JWT_EXPIRED; } } @@ -146,6 +147,7 @@ int analyze_jwt (const cjwt_t *jwt, char **url_buf, unsigned int *port) url_buf, port); if (http_match < 0) { ParodusError ("Invalid endpoint claim in JWT\n"); + OnboardLog("Invalid endpoint claim in JWT\n"); return TOKEN_ERR_BAD_ENDPOINT; } ParodusInfo ("JWT is_http strncmp: %d\n", http_match); diff --git a/src/upstream.c b/src/upstream.c index 7b75d9c..799427e 100644 --- a/src/upstream.c +++ b/src/upstream.c @@ -589,6 +589,7 @@ void sendUpstreamMsgToServer(void **resp_bytes, size_t resp_size) else { ParodusInfo("close_retry is %d, unable to send response as connection retry is in progress\n", close_retry); + OnboardLog("close_retry is %d, unable to send response as connection retry is in progress\n", close_retry); } free(appendData); appendData =NULL;