Browse Source

Rename generic `error` function (#15296)

thiagoftsm 1 year ago
parent
commit
e0f388c43f
10 changed files with 128 additions and 128 deletions
  1. 18 18
      aclk/aclk.c
  2. 65 65
      aclk/aclk_otp.c
  3. 1 1
      aclk/aclk_proxy.c
  4. 4 4
      aclk/aclk_query.c
  5. 2 2
      aclk/aclk_query_queue.c
  6. 1 1
      aclk/aclk_query_queue.h
  7. 16 16
      aclk/aclk_rx_msgs.c
  8. 2 2
      aclk/aclk_stats.c
  9. 7 7
      aclk/aclk_tx_msgs.c
  10. 12 12
      aclk/aclk_util.c

+ 18 - 18
aclk/aclk.c

@@ -72,7 +72,7 @@ static void aclk_ssl_keylog_cb(const SSL *ssl, const char *line)
     if (!ssl_log_file)
         ssl_log_file = fopen(ssl_log_filename, "a");
     if (!ssl_log_file) {
-        error("Couldn't open ssl_log file (%s) for append.", ssl_log_filename);
+        netdata_log_error("Couldn't open ssl_log file (%s) for append.", ssl_log_filename);
         return;
     }
     fputs(line, ssl_log_file);
@@ -107,14 +107,14 @@ static int load_private_key()
     long bytes_read;
     char *private_key = read_by_filename(filename, &bytes_read);
     if (!private_key) {
-        error("Claimed agent cannot establish ACLK - unable to load private key '%s' failed.", filename);
+        netdata_log_error("Claimed agent cannot establish ACLK - unable to load private key '%s' failed.", filename);
         return 1;
     }
     debug(D_ACLK, "Claimed agent loaded private key len=%ld bytes", bytes_read);
 
     BIO *key_bio = BIO_new_mem_buf(private_key, -1);
     if (key_bio==NULL) {
-        error("Claimed agent cannot establish ACLK - failed to create BIO for key");
+        netdata_log_error("Claimed agent cannot establish ACLK - failed to create BIO for key");
         goto biofailed;
     }
 
@@ -125,13 +125,13 @@ static int load_private_key()
                                               NULL, NULL);
 
     if (!aclk_dctx) {
-        error("Loading private key (from claiming) failed - no OpenSSL Decoders found");
+        netdata_log_error("Loading private key (from claiming) failed - no OpenSSL Decoders found");
         goto biofailed;
     }
 
     // this is necesseary to avoid RSA key with wrong size
     if (!OSSL_DECODER_from_bio(aclk_dctx, key_bio)) {
-        error("Decoding private key (from claiming) failed - invalid format.");
+        netdata_log_error("Decoding private key (from claiming) failed - invalid format.");
         goto biofailed;
     }
 #else
@@ -145,7 +145,7 @@ static int load_private_key()
     }
     char err[512];
     ERR_error_string_n(ERR_get_error(), err, sizeof(err));
-    error("Claimed agent cannot establish ACLK - cannot create private key: %s", err);
+    netdata_log_error("Claimed agent cannot establish ACLK - cannot create private key: %s", err);
 
 biofailed:
     freez(private_key);
@@ -204,7 +204,7 @@ static int wait_till_agent_claim_ready()
         // We trap the impossible NULL here to keep the linter happy without using a fatal() in the code.
         char *cloud_base_url = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "cloud base url", NULL);
         if (cloud_base_url == NULL) {
-            error("Do not move the cloud base url out of post_conf_load!!");
+            netdata_log_error("Do not move the cloud base url out of post_conf_load!!");
             return 1;
         }
 
@@ -212,7 +212,7 @@ static int wait_till_agent_claim_ready()
         // TODO make it without malloc/free
         memset(&url, 0, sizeof(url_t));
         if (url_parse(cloud_base_url, &url)) {
-            error("Agent is claimed but the URL in configuration key \"cloud base url\" is invalid, please fix");
+            netdata_log_error("Agent is claimed but the URL in configuration key \"cloud base url\" is invalid, please fix");
             url_t_destroy(&url);
             sleep(5);
             continue;
@@ -243,7 +243,7 @@ void aclk_mqtt_wss_log_cb(mqtt_wss_log_type_t log_type, const char* str)
             debug(D_ACLK, "%s", str);
             return;
         default:
-            error("Unknown log type from mqtt_wss");
+            netdata_log_error("Unknown log type from mqtt_wss");
     }
 }
 
@@ -255,7 +255,7 @@ static void msg_callback(const char *topic, const void *msg, size_t msglen, int
     debug(D_ACLK, "Got Message From Broker Topic \"%s\" QOS %d", topic, qos);
 
     if (aclk_shared_state.mqtt_shutdown_msg_id > 0) {
-        error("Link is shutting down. Ignoring incoming message.");
+        netdata_log_error("Link is shutting down. Ignoring incoming message.");
         return;
     }
 
@@ -277,7 +277,7 @@ static void msg_callback(const char *topic, const void *msg, size_t msglen, int
     snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx-%s.bin", ACLK_GET_CONV_LOG_NEXT(), msgtype);
     logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
     if(logfd < 0)
-        error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
+        netdata_log_error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
     write(logfd, msg, msglen);
     close(logfd);
 #endif
@@ -308,7 +308,7 @@ static int read_query_thread_count()
     threads = MAX(threads, 2);
     threads = config_get_number(CONFIG_SECTION_CLOUD, "query thread count", threads);
     if(threads < 1) {
-        error("You need at least one query thread. Overriding configured setting of \"%d\"", threads);
+        netdata_log_error("You need at least one query thread. Overriding configured setting of \"%d\"", threads);
         threads = 1;
         config_set_number(CONFIG_SECTION_CLOUD, "query thread count", threads);
     }
@@ -365,13 +365,13 @@ static inline void mqtt_connected_actions(mqtt_wss_client client)
     char *topic = (char*)aclk_get_topic(ACLK_TOPICID_COMMAND);
 
     if (!topic)
-        error("Unable to fetch topic for COMMAND (to subscribe)");
+        netdata_log_error("Unable to fetch topic for COMMAND (to subscribe)");
     else
         mqtt_wss_subscribe(client, topic, 1);
 
     topic = (char*)aclk_get_topic(ACLK_TOPICID_CMD_NG_V1);
     if (!topic)
-        error("Unable to fetch topic for protobuf COMMAND (to subscribe)");
+        netdata_log_error("Unable to fetch topic for protobuf COMMAND (to subscribe)");
     else
         mqtt_wss_subscribe(client, topic, 1);
 
@@ -399,7 +399,7 @@ void aclk_graceful_disconnect(mqtt_wss_client client)
     time_t t = now_monotonic_sec();
     while (!mqtt_wss_service(client, 100)) {
         if (now_monotonic_sec() - t >= 2) {
-            error("Wasn't able to gracefully shutdown ACLK in time!");
+            netdata_log_error("Wasn't able to gracefully shutdown ACLK in time!");
             break;
         }
         if (aclk_shared_state.mqtt_shutdown_msg_rcvd) {
@@ -786,7 +786,7 @@ void *aclk_main(void *ptr)
     ACLK_PROXY_TYPE proxy_type;
     aclk_get_proxy(&proxy_type);
     if (proxy_type == PROXY_TYPE_SOCKS5) {
-        error("SOCKS5 proxy is not supported by ACLK-NG yet.");
+        netdata_log_error("SOCKS5 proxy is not supported by ACLK-NG yet.");
         static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
         return NULL;
     }
@@ -811,7 +811,7 @@ void *aclk_main(void *ptr)
         goto exit;
 
     if (!(mqttwss_client = mqtt_wss_new("mqtt_wss", aclk_mqtt_wss_log_cb, msg_callback, puback_callback))) {
-        error("Couldn't initialize MQTT_WSS network library");
+        netdata_log_error("Couldn't initialize MQTT_WSS network library");
         goto exit;
     }
 
@@ -906,7 +906,7 @@ void aclk_host_state_update(RRDHOST *host, int cmd)
         ret = get_node_id(&host->host_uuid, &node_id);
         if (ret > 0) {
             // this means we were not able to check if node_id already present
-            error("Unable to check for node_id. Ignoring the host state update.");
+            netdata_log_error("Unable to check for node_id. Ignoring the host state update.");
             return;
         }
         if (ret < 0) {

+ 65 - 65
aclk/aclk_otp.c

@@ -38,7 +38,7 @@ struct auth_data {
 
 #define PARSE_ENV_JSON_CHK_TYPE(it, type, name)                                                                        \
     if (json_object_get_type(json_object_iter_peek_value(it)) != type) {                                               \
-        error("value of key \"%s\" should be %s", name, #type);                                                        \
+        netdata_log_error("value of key \"%s\" should be %s", name, #type);                                            \
         goto exit;                                                                                                     \
     }
 
@@ -55,7 +55,7 @@ static int parse_passwd_response(const char *json_str, struct auth_data *auth) {
 
     json = json_tokener_parse(json_str);
     if (!json) {
-        error("JSON-C failed to parse the payload of http response of /env endpoint");
+        netdata_log_error("JSON-C failed to parse the payload of http response of /env endpoint");
         return 1;
     }
 
@@ -88,26 +88,26 @@ static int parse_passwd_response(const char *json_str, struct auth_data *auth) {
             PARSE_ENV_JSON_CHK_TYPE(&it, json_type_array, JSON_KEY_TOPICS)
 
             if (aclk_generate_topic_cache(json_object_iter_peek_value(&it))) {
-                error("Failed to generate topic cache!");
+                netdata_log_error("Failed to generate topic cache!");
                 goto exit;
             }
             json_object_iter_next(&it);
             continue;
         }
-        error("Unknown key \"%s\" in passwd response payload. Ignoring", json_object_iter_peek_name(&it));
+        netdata_log_error("Unknown key \"%s\" in passwd response payload. Ignoring", json_object_iter_peek_name(&it));
         json_object_iter_next(&it);
     }
 
     if (!auth->client_id) {
-        error(JSON_KEY_CLIENTID " is compulsory key in /password response");
+        netdata_log_error(JSON_KEY_CLIENTID " is compulsory key in /password response");
         goto exit;
     }
     if (!auth->passwd) {
-        error(JSON_KEY_PASS " is compulsory in /password response");
+        netdata_log_error(JSON_KEY_PASS " is compulsory in /password response");
         goto exit;
     }
     if (!auth->username) {
-        error(JSON_KEY_USER " is compulsory in /password response");
+        netdata_log_error(JSON_KEY_USER " is compulsory in /password response");
         goto exit;
     }
 
@@ -126,11 +126,11 @@ exit:
 static const char *get_json_str_by_path(json_object *json, const char *path) {
     json_object *ptr;
     if (json_pointer_get(json, path, &ptr)) {
-        error("Missing compulsory key \"%s\" in error response", path);
+        netdata_log_error("Missing compulsory key \"%s\" in error response", path);
         return NULL;
     }
     if (json_object_get_type(ptr) != json_type_string) {
-        error("Value of Key \"%s\" in error response should be string", path);
+        netdata_log_error("Value of Key \"%s\" in error response should be string", path);
         return NULL;
     }
     return json_object_get_string(ptr);
@@ -147,7 +147,7 @@ static int aclk_parse_otp_error(const char *json_str) {
 
     json = json_tokener_parse(json_str);
     if (!json) {
-        error("JSON-C failed to parse the payload of http response of /env endpoint");
+        netdata_log_error("JSON-C failed to parse the payload of http response of /env endpoint");
         return 1;
     }
 
@@ -163,7 +163,7 @@ static int aclk_parse_otp_error(const char *json_str) {
     // optional field
     if (!json_pointer_get(json, "/" JSON_KEY_ERTRY, &ptr)) {
         if (json_object_get_type(ptr) != json_type_boolean) {
-            error("Error response Key " "/" JSON_KEY_ERTRY " should be of boolean type");
+            netdata_log_error("Error response Key " "/" JSON_KEY_ERTRY " should be of boolean type");
             goto exit;
         }
         block_retry = json_object_get_boolean(ptr);
@@ -172,7 +172,7 @@ static int aclk_parse_otp_error(const char *json_str) {
     // optional field
     if (!json_pointer_get(json, "/" JSON_KEY_EDELAY, &ptr)) {
         if (json_object_get_type(ptr) != json_type_int) {
-            error("Error response Key " "/" JSON_KEY_EDELAY " should be of integer type");
+            netdata_log_error("Error response Key " "/" JSON_KEY_EDELAY " should be of integer type");
             goto exit;
         }
         backoff = json_object_get_int(ptr);
@@ -184,7 +184,7 @@ static int aclk_parse_otp_error(const char *json_str) {
     if (backoff > 0)
         aclk_block_until = now_monotonic_sec() + backoff;
 
-    error("Cloud returned EC=\"%s\", Msg-Key:\"%s\", Msg:\"%s\", BlockRetry:%s, Backoff:%ds (-1 unset by cloud)", ec, ek, emsg, block_retry > 0 ? "true" : "false", backoff);
+    netdata_log_error("Cloud returned EC=\"%s\", Msg-Key:\"%s\", Msg:\"%s\", BlockRetry:%s, Backoff:%ds (-1 unset by cloud)", ec, ek, emsg, block_retry > 0 ? "true" : "false", backoff);
     rc = 0;
 exit:
     json_object_put(json);
@@ -205,7 +205,7 @@ static int aclk_parse_otp_error(const char *json_str) {
 
     json = json_tokener_parse(json_str);
     if (!json) {
-        error("JSON-C failed to parse the payload of http response of /env endpoint");
+        netdata_log_error("JSON-C failed to parse the payload of http response of /env endpoint");
         return 1;
     }
 
@@ -236,7 +236,7 @@ static int aclk_parse_otp_error(const char *json_str) {
         }
         if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_EDELAY)) {
             if (json_object_get_type(json_object_iter_peek_value(&it)) != json_type_int) {
-                error("value of key " JSON_KEY_EDELAY " should be integer");
+                netdata_log_error("value of key " JSON_KEY_EDELAY " should be integer");
                 goto exit;
             }
 
@@ -246,7 +246,7 @@ static int aclk_parse_otp_error(const char *json_str) {
         }
         if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_ERTRY)) {
             if (json_object_get_type(json_object_iter_peek_value(&it)) != json_type_boolean) {
-                error("value of key " JSON_KEY_ERTRY " should be integer");
+                netdata_log_error("value of key " JSON_KEY_ERTRY " should be integer");
                 goto exit;
             }
 
@@ -254,7 +254,7 @@ static int aclk_parse_otp_error(const char *json_str) {
             json_object_iter_next(&it);
             continue;
         }
-        error("Unknown key \"%s\" in error response payload. Ignoring", json_object_iter_peek_name(&it));
+        netdata_log_error("Unknown key \"%s\" in error response payload. Ignoring", json_object_iter_peek_name(&it));
         json_object_iter_next(&it);
     }
 
@@ -264,7 +264,7 @@ static int aclk_parse_otp_error(const char *json_str) {
     if (backoff > 0)
         aclk_block_until = now_monotonic_sec() + backoff;
 
-    error("Cloud returned EC=\"%s\", Msg-Key:\"%s\", Msg:\"%s\", BlockRetry:%s, Backoff:%ds (-1 unset by cloud)", ec, ek, emsg, block_retry > 0 ? "true" : "false", backoff);
+    netdata_log_error("Cloud returned EC=\"%s\", Msg-Key:\"%s\", Msg:\"%s\", BlockRetry:%s, Backoff:%ds (-1 unset by cloud)", ec, ek, emsg, block_retry > 0 ? "true" : "false", backoff);
     rc = 0;
 exit:
     json_object_put(json);
@@ -301,7 +301,7 @@ inline static int base64_decode_helper(unsigned char *out, int *outl, const unsi
     EVP_DecodeFinal(ctx, remaining_data, &remainder);
     EVP_ENCODE_CTX_free(ctx);
     if (remainder) {
-        error("Unexpected data at EVP_DecodeFinal");
+        netdata_log_error("Unexpected data at EVP_DecodeFinal");
         return 1;
     }
     return 0;
@@ -322,12 +322,12 @@ int aclk_get_otp_challenge(url_t *target, const char *agent_id, unsigned char **
     req.url = (char *)buffer_tostring(url);
 
     if (aclk_https_request(&req, &resp)) {
-        error ("ACLK_OTP Challenge failed");
+        netdata_log_error("ACLK_OTP Challenge failed");
         buffer_free(url);
         return 1;
     }
     if (resp.http_code != 200) {
-        error ("ACLK_OTP Challenge HTTP code not 200 OK (got %d)", resp.http_code);
+        netdata_log_error("ACLK_OTP Challenge HTTP code not 200 OK (got %d)", resp.http_code);
         buffer_free(url);
         if (resp.payload_size)
             aclk_parse_otp_error(resp.payload);
@@ -339,32 +339,32 @@ int aclk_get_otp_challenge(url_t *target, const char *agent_id, unsigned char **
 
     json_object *json = json_tokener_parse(resp.payload);
     if (!json) {
-        error ("Couldn't parse HTTP GET challenge payload");
+        netdata_log_error("Couldn't parse HTTP GET challenge payload");
         goto cleanup_resp;
     }
     json_object *challenge_json;
     if (!json_object_object_get_ex(json, "challenge", &challenge_json)) {
-        error ("No key named \"challenge\" in the returned JSON");
+        netdata_log_error("No key named \"challenge\" in the returned JSON");
         goto cleanup_json;
     }
     if (!json_object_is_type(challenge_json, json_type_string)) {
-        error ("\"challenge\" is not a string JSON type");
+        netdata_log_error("\"challenge\" is not a string JSON type");
         goto cleanup_json;
     }
     const char *challenge_base64;
     if (!(challenge_base64 = json_object_get_string(challenge_json))) {
-        error("Failed to extract challenge from JSON object");
+        netdata_log_error("Failed to extract challenge from JSON object");
         goto cleanup_json;
     }
     if (strlen(challenge_base64) != CHALLENGE_LEN_BASE64) {
-        error("Received Challenge has unexpected length of %zu (expected %d)", strlen(challenge_base64), CHALLENGE_LEN_BASE64);
+        netdata_log_error("Received Challenge has unexpected length of %zu (expected %d)", strlen(challenge_base64), CHALLENGE_LEN_BASE64);
         goto cleanup_json;
     }
 
     *challenge = mallocz((CHALLENGE_LEN_BASE64 / 4) * 3);
     base64_decode_helper(*challenge, challenge_bytes, (const unsigned char*)challenge_base64, strlen(challenge_base64));
     if (*challenge_bytes != CHALLENGE_LEN) {
-        error("Unexpected challenge length of %d instead of %d", *challenge_bytes, CHALLENGE_LEN);
+        netdata_log_error("Unexpected challenge length of %d instead of %d", *challenge_bytes, CHALLENGE_LEN);
         freez(*challenge);
         *challenge = NULL;
         goto cleanup_json;
@@ -405,11 +405,11 @@ int aclk_send_otp_response(const char *agent_id, const unsigned char *response,
     req.payload_size = strlen(req.payload);
 
     if (aclk_https_request(&req, &resp)) {
-        error ("ACLK_OTP Password error trying to post result to password");
+        netdata_log_error("ACLK_OTP Password error trying to post result to password");
         goto cleanup_buffers;
     }
     if (resp.http_code != 201) {
-        error ("ACLK_OTP Password HTTP code not 201 Created (got %d)", resp.http_code);
+        netdata_log_error("ACLK_OTP Password HTTP code not 201 Created (got %d)", resp.http_code);
         if (resp.payload_size)
             aclk_parse_otp_error(resp.payload);
         goto cleanup_response;
@@ -417,7 +417,7 @@ int aclk_send_otp_response(const char *agent_id, const unsigned char *response,
     netdata_log_info("ACLK_OTP Got Password from Cloud");
 
     if (parse_passwd_response(resp.payload, mqtt_auth)){
-        error("Error parsing response of password endpoint");
+        netdata_log_error("Error parsing response of password endpoint");
         goto cleanup_response;
     }
 
@@ -470,7 +470,7 @@ static int private_decrypt(RSA *p_key, unsigned char * enc_data, int data_len, u
     {
         char err[512];
         ERR_error_string_n(ERR_get_error(), err, sizeof(err));
-        error("Decryption of the challenge failed: %s", err);
+        netdata_log_error("Decryption of the challenge failed: %s", err);
     }
     return result;
 }
@@ -486,13 +486,13 @@ int aclk_get_mqtt_otp(RSA *p_key, char **mqtt_id, char **mqtt_usr, char **mqtt_p
 
     char *agent_id = get_agent_claimid();
     if (agent_id == NULL) {
-        error("Agent was not claimed - cannot perform challenge/response");
+        netdata_log_error("Agent was not claimed - cannot perform challenge/response");
         return 1;
     }
 
     // Get Challenge
     if (aclk_get_otp_challenge(target, agent_id, &challenge, &challenge_bytes)) {
-        error("Error getting challenge");
+        netdata_log_error("Error getting challenge");
         freez(agent_id);
         return 1;
     }
@@ -501,7 +501,7 @@ int aclk_get_mqtt_otp(RSA *p_key, char **mqtt_id, char **mqtt_usr, char **mqtt_p
     unsigned char *response_plaintext;
     int response_plaintext_bytes = private_decrypt(p_key, challenge, challenge_bytes, &response_plaintext);
     if (response_plaintext_bytes < 0) {
-        error ("Couldn't decrypt the challenge received");
+        netdata_log_error("Couldn't decrypt the challenge received");
         freez(response_plaintext);
         freez(challenge);
         freez(agent_id);
@@ -512,7 +512,7 @@ int aclk_get_mqtt_otp(RSA *p_key, char **mqtt_id, char **mqtt_usr, char **mqtt_p
     // Encode and Send Challenge
     struct auth_data data = { .client_id = NULL, .passwd = NULL, .username = NULL };
     if (aclk_send_otp_response(agent_id, response_plaintext, response_plaintext_bytes, target, &data)) {
-        error("Error getting response");
+        netdata_log_error("Error getting response");
         freez(response_plaintext);
         freez(agent_id);
         return 1;
@@ -549,12 +549,12 @@ static int parse_json_env_transport(json_object *json, aclk_transport_desc_t *tr
         if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_TRP_TYPE)) {
             PARSE_ENV_JSON_CHK_TYPE(&it, json_type_string, JSON_KEY_TRP_TYPE)
             if (trp->type != ACLK_TRP_UNKNOWN) {
-                error(JSON_KEY_TRP_TYPE " set already");
+                netdata_log_error(JSON_KEY_TRP_TYPE " set already");
                 goto exit;
             }
             trp->type = aclk_transport_type_t_from_str(json_object_get_string(json_object_iter_peek_value(&it)));
             if (trp->type == ACLK_TRP_UNKNOWN) {
-                error(JSON_KEY_TRP_TYPE " unknown type \"%s\"", json_object_get_string(json_object_iter_peek_value(&it)));
+                netdata_log_error(JSON_KEY_TRP_TYPE " unknown type \"%s\"", json_object_get_string(json_object_iter_peek_value(&it)));
                 goto exit;
             }
             json_object_iter_next(&it);
@@ -564,25 +564,25 @@ static int parse_json_env_transport(json_object *json, aclk_transport_desc_t *tr
         if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_TRP_ENDPOINT)) {
             PARSE_ENV_JSON_CHK_TYPE(&it, json_type_string, JSON_KEY_TRP_ENDPOINT)
             if (trp->endpoint) {
-                error(JSON_KEY_TRP_ENDPOINT " set already");
+                netdata_log_error(JSON_KEY_TRP_ENDPOINT " set already");
                 goto exit;
             }
             trp->endpoint = strdupz(json_object_get_string(json_object_iter_peek_value(&it)));
             json_object_iter_next(&it);
             continue;
         }
-        
-        error ("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
+
+        netdata_log_error("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
         json_object_iter_next(&it);
     }
 
     if (!trp->endpoint) {
-        error (JSON_KEY_TRP_ENDPOINT " is missing from JSON dictionary");
+        netdata_log_error(JSON_KEY_TRP_ENDPOINT " is missing from JSON dictionary");
         goto exit;
     }
 
     if (trp->type == ACLK_TRP_UNKNOWN) {
-        error ("transport type not set");
+        netdata_log_error("transport type not set");
         goto exit;
     }
 
@@ -598,7 +598,7 @@ static int parse_json_env_transports(json_object *json_array, aclk_env_t *env) {
     json_object *obj;
 
     if (env->transports) {
-        error("transports have been set already");
+        netdata_log_error("transports have been set already");
         return 1;
     }
 
@@ -610,7 +610,7 @@ static int parse_json_env_transports(json_object *json_array, aclk_env_t *env) {
         trp = callocz(1, sizeof(aclk_transport_desc_t));
         obj = json_object_array_get_idx(json_array, i);
         if (parse_json_env_transport(obj, trp)) {
-            error("error parsing transport idx %d", (int)i);
+            netdata_log_error("error parsing transport idx %d", (int)i);
             freez(trp);
             return 1;
         }
@@ -626,14 +626,14 @@ static int parse_json_env_transports(json_object *json_array, aclk_env_t *env) {
 static int parse_json_backoff_int(struct json_object_iterator *it, int *out, const char* name, int min, int max) {
     if (!strcmp(json_object_iter_peek_name(it), name)) {
         if (json_object_get_type(json_object_iter_peek_value(it)) != json_type_int) {
-            error("Could not parse \"%s\". Not an integer as expected.", name);
+            netdata_log_error("Could not parse \"%s\". Not an integer as expected.", name);
             return MATCHED_ERROR;
         }
 
         *out = json_object_get_int(json_object_iter_peek_value(it));
 
         if (*out < min || *out > max) {
-            error("Value of \"%s\"=%d out of range (%d-%d).", name, *out, min, max);
+            netdata_log_error("Value of \"%s\"=%d out of range (%d-%d).", name, *out, min, max);
             return MATCHED_ERROR;
         }
 
@@ -675,7 +675,7 @@ static int parse_json_backoff(json_object *json, aclk_backoff_t *backoff) {
             continue;
         }
 
-        error ("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
+        netdata_log_error("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
         json_object_iter_next(&it);
     }
 
@@ -687,7 +687,7 @@ static int parse_json_env_caps(json_object *json, aclk_env_t *env) {
     const char *str;
 
     if (env->capabilities) {
-        error("transports have been set already");
+        netdata_log_error("transports have been set already");
         return 1;
     }
 
@@ -702,12 +702,12 @@ static int parse_json_env_caps(json_object *json, aclk_env_t *env) {
     for (size_t i = 0; i < env->capability_count; i++) {
         obj = json_object_array_get_idx(json, i);
         if (json_object_get_type(obj) != json_type_string) {
-            error("Capability at index %d not a string!", (int)i);
+            netdata_log_error("Capability at index %d not a string!", (int)i);
             return 1;
         }
         str = json_object_get_string(obj);
         if (!str) {
-            error("Error parsing capabilities");
+            netdata_log_error("Error parsing capabilities");
             return 1;
         }
         env->capabilities[i] = strdupz(str);
@@ -723,7 +723,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
 
     json = json_tokener_parse(json_str);
     if (!json) {
-        error("JSON-C failed to parse the payload of http response of /env endpoint");
+        netdata_log_error("JSON-C failed to parse the payload of http response of /env endpoint");
         return 1;
     }
 
@@ -734,7 +734,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
         if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_AUTH_ENDPOINT)) {
             PARSE_ENV_JSON_CHK_TYPE(&it, json_type_string, JSON_KEY_AUTH_ENDPOINT)
             if (env->auth_endpoint) {
-                error("authEndpoint set already");
+                netdata_log_error("authEndpoint set already");
                 goto exit;
             }
             env->auth_endpoint = strdupz(json_object_get_string(json_object_iter_peek_value(&it)));
@@ -745,7 +745,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
         if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_ENC)) {
             PARSE_ENV_JSON_CHK_TYPE(&it, json_type_string, JSON_KEY_ENC)
             if (env->encoding != ACLK_ENC_UNKNOWN) {
-                error(JSON_KEY_ENC " set already");
+                netdata_log_error(JSON_KEY_ENC " set already");
                 goto exit;
             }
             env->encoding = aclk_encoding_type_t_from_str(json_object_get_string(json_object_iter_peek_value(&it)));
@@ -768,7 +768,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
 
             if (parse_json_backoff(json_object_iter_peek_value(&it), &env->backoff)) {
                 env->backoff.base = 0;
-                error("Error parsing Backoff parameters in env");
+                netdata_log_error("Error parsing Backoff parameters in env");
                 goto exit;
             }
 
@@ -780,7 +780,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
             PARSE_ENV_JSON_CHK_TYPE(&it, json_type_array, JSON_KEY_CAPS)
 
             if (parse_json_env_caps(json_object_iter_peek_value(&it), env)) {
-                error("Error parsing capabilities list");
+                netdata_log_error("Error parsing capabilities list");
                 goto exit;
             }
 
@@ -788,25 +788,25 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
             continue;
         }
 
-        error ("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
+        netdata_log_error("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
         json_object_iter_next(&it);
     }
 
     // Check all compulsory keys have been set
     if (env->transport_count < 1) {
-        error("env has to return at least one transport");
+        netdata_log_error("env has to return at least one transport");
         goto exit;
     }
     if (!env->auth_endpoint) {
-        error(JSON_KEY_AUTH_ENDPOINT " is compulsory");
+        netdata_log_error(JSON_KEY_AUTH_ENDPOINT " is compulsory");
         goto exit;
     }
     if (env->encoding == ACLK_ENC_UNKNOWN) {
-        error(JSON_KEY_ENC " is compulsory");
+        netdata_log_error(JSON_KEY_ENC " is compulsory");
         goto exit;
     }
     if (!env->backoff.base) {
-        error(JSON_KEY_BACKOFF " is compulsory");
+        netdata_log_error(JSON_KEY_BACKOFF " is compulsory");
         goto exit;
     }
 
@@ -830,7 +830,7 @@ int aclk_get_env(aclk_env_t *env, const char* aclk_hostname, int aclk_port) {
     char *agent_id = get_agent_claimid();
     if (agent_id == NULL)
     {
-        error("Agent was not claimed - cannot perform challenge/response");
+        netdata_log_error("Agent was not claimed - cannot perform challenge/response");
         buffer_free(buf);
         return 1;
     }
@@ -843,13 +843,13 @@ int aclk_get_env(aclk_env_t *env, const char* aclk_hostname, int aclk_port) {
     req.port = aclk_port;
     req.url = buf->buffer;
     if (aclk_https_request(&req, &resp)) {
-        error("Error trying to contact env endpoint");
+        netdata_log_error("Error trying to contact env endpoint");
         https_req_response_free(&resp);
         buffer_free(buf);
         return 2;
     }
     if (resp.http_code != 200) {
-        error("The HTTP code not 200 OK (Got %d)", resp.http_code);
+        netdata_log_error("The HTTP code not 200 OK (Got %d)", resp.http_code);
         if (resp.payload_size)
             aclk_parse_otp_error(resp.payload);
         https_req_response_free(&resp);
@@ -858,14 +858,14 @@ int aclk_get_env(aclk_env_t *env, const char* aclk_hostname, int aclk_port) {
     }
 
     if (!resp.payload || !resp.payload_size) {
-        error("Unexpected empty payload as response to /env call");
+        netdata_log_error("Unexpected empty payload as response to /env call");
         https_req_response_free(&resp);
         buffer_free(buf);
         return 4;
     }
 
     if (parse_json_env(resp.payload, env)) {
-        error ("error parsing /env message");
+        netdata_log_error("error parsing /env message");
         https_req_response_free(&resp);
         buffer_free(buf);
         return 5;

+ 1 - 1
aclk/aclk_proxy.c

@@ -85,7 +85,7 @@ static inline void safe_log_proxy_error(char *str, const char *proxy)
 {
     char *log = strdupz(proxy);
     safe_log_proxy_censor(log);
-    error("%s Provided Value:\"%s\"", str, log);
+    netdata_log_error("%s Provided Value:\"%s\"", str, log);
     freez(log);
 }
 

+ 4 - 4
aclk/aclk_query.c

@@ -164,7 +164,7 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
                 w->response.zinitialized = true;
                 w->response.zoutput = true;
             } else
-                error("Failed to initialize zlib. Proceeding without compression.");
+                netdata_log_error("Failed to initialize zlib. Proceeding without compression.");
         }
     }
 
@@ -177,9 +177,9 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
             z_ret = deflate(&w->response.zstream, Z_FINISH);
             if(z_ret < 0) {
                 if(w->response.zstream.msg)
-                    error("Error compressing body. ZLIB error: \"%s\"", w->response.zstream.msg);
+                    netdata_log_error("Error compressing body. ZLIB error: \"%s\"", w->response.zstream.msg);
                 else
-                    error("Unknown error during zlib compression.");
+                    netdata_log_error("Unknown error during zlib compression.");
                 retval = 1;
                 w->response.code = 500;
                 aclk_http_msg_v2_err(query_thr->client, query->callback_topic, query->msg_id, w->response.code, CLOUD_EC_ZLIB_ERROR, CLOUD_EMSG_ZLIB_ERROR, NULL, 0);
@@ -366,7 +366,7 @@ void aclk_query_threads_start(struct aclk_query_threads *query_threads, mqtt_wss
         query_threads->thread_list[i].client = client;
 
         if(unlikely(snprintfz(thread_name, TASK_LEN_MAX, "ACLK_QRY[%d]", i) < 0))
-            error("snprintf encoding error");
+            netdata_log_error("snprintf encoding error");
         netdata_thread_create(
             &query_threads->thread_list[i].thread, thread_name, NETDATA_THREAD_OPTION_JOINABLE, aclk_query_main_thread,
             &query_threads->thread_list[i]);

+ 2 - 2
aclk/aclk_query_queue.c

@@ -27,7 +27,7 @@ static inline int _aclk_queue_query(aclk_query_t query)
     if (aclk_query_queue.block_push) {
         ACLK_QUEUE_UNLOCK;
         if(service_running(SERVICE_ACLK | ABILITY_DATA_QUERIES))
-            error("Query Queue is blocked from accepting new requests. This is normally the case when ACLK prepares to shutdown.");
+            netdata_log_error("Query Queue is blocked from accepting new requests. This is normally the case when ACLK prepares to shutdown.");
         aclk_query_free(query);
         return 1;
     }
@@ -67,7 +67,7 @@ aclk_query_t aclk_queue_pop(void)
     if (aclk_query_queue.block_push) {
         ACLK_QUEUE_UNLOCK;
         if(service_running(SERVICE_ACLK | ABILITY_DATA_QUERIES))
-            error("POP Query Queue is blocked from accepting new requests. This is normally the case when ACLK prepares to shutdown.");
+            netdata_log_error("POP Query Queue is blocked from accepting new requests. This is normally the case when ACLK prepares to shutdown.");
         return NULL;
     }
 

+ 1 - 1
aclk/aclk_query_queue.h

@@ -79,7 +79,7 @@ void aclk_queue_unlock(void);
     if (likely(query->data.bin_payload.payload)) {                                                                     \
         aclk_queue_query(query);                                                                                       \
     } else {                                                                                                           \
-        error("Failed to generate payload (%s)", __FUNCTION__);                                                        \
+        netdata_log_error("Failed to generate payload (%s)", __FUNCTION__);                                            \
         aclk_query_free(query);                                                                                        \
     }
 

+ 16 - 16
aclk/aclk_rx_msgs.c

@@ -103,14 +103,14 @@ static inline int aclk_v2_payload_get_query(const char *payload, char **query_ur
     // TODO better check of URL
     if(strncmp(payload, ACLK_CLOUD_REQ_V2_PREFIX, strlen(ACLK_CLOUD_REQ_V2_PREFIX))) {
         errno = 0;
-        error("Only accepting requests that start with \"%s\" from CLOUD.", ACLK_CLOUD_REQ_V2_PREFIX);
+        netdata_log_error("Only accepting requests that start with \"%s\" from CLOUD.", ACLK_CLOUD_REQ_V2_PREFIX);
         return 1;
     }
     start = payload + 4;
 
     if(!(end = strstr(payload, " HTTP/1.1\x0D\x0A"))) {
         errno = 0;
-        error("Doesn't look like HTTP GET request.");
+        netdata_log_error("Doesn't look like HTTP GET request.");
         return 1;
     }
 
@@ -126,7 +126,7 @@ static int aclk_handle_cloud_http_request_v2(struct aclk_request *cloud_to_agent
 
     errno = 0;
     if (cloud_to_agent->version < ACLK_V_COMPRESSION) {
-        error(
+        netdata_log_error(
             "This handler cannot reply to request with version older than %d, received %d.",
             ACLK_V_COMPRESSION,
             cloud_to_agent->version);
@@ -136,22 +136,22 @@ static int aclk_handle_cloud_http_request_v2(struct aclk_request *cloud_to_agent
     query = aclk_query_new(HTTP_API_V2);
 
     if (unlikely(aclk_extract_v2_data(raw_payload, &query->data.http_api_v2.payload))) {
-        error("Error extracting payload expected after the JSON dictionary.");
+        netdata_log_error("Error extracting payload expected after the JSON dictionary.");
         goto error;
     }
 
     if (unlikely(aclk_v2_payload_get_query(query->data.http_api_v2.payload, &query->dedup_id))) {
-        error("Could not extract payload from query");
+        netdata_log_error("Could not extract payload from query");
         goto error;
     }
 
     if (unlikely(!cloud_to_agent->callback_topic)) {
-        error("Missing callback_topic");
+        netdata_log_error("Missing callback_topic");
         goto error;
     }
 
     if (unlikely(!cloud_to_agent->msg_id)) {
-        error("Missing msg_id");
+        netdata_log_error("Missing msg_id");
         goto error;
     }
 
@@ -254,13 +254,13 @@ int create_node_instance_result(const char *msg, size_t msg_len)
 
     uuid_t host_id, node_id;
     if (uuid_parse(res.machine_guid, host_id)) {
-        error("Error parsing machine_guid provided by CreateNodeInstanceResult");
+        netdata_log_error("Error parsing machine_guid provided by CreateNodeInstanceResult");
         freez(res.machine_guid);
         freez(res.node_id);
         return 1;
     }
     if (uuid_parse(res.node_id, node_id)) {
-        error("Error parsing node_id provided by CreateNodeInstanceResult");
+        netdata_log_error("Error parsing node_id provided by CreateNodeInstanceResult");
         freez(res.machine_guid);
         freez(res.node_id);
         return 1;
@@ -341,7 +341,7 @@ int start_alarm_streaming(const char *msg, size_t msg_len)
 {
     struct start_alarm_streaming res = parse_start_alarm_streaming(msg, msg_len);
     if (!res.node_id) {
-        error("Error parsing StartAlarmStreaming");
+        netdata_log_error("Error parsing StartAlarmStreaming");
         return 1;
     }
     aclk_start_alert_streaming(res.node_id, res.resets);
@@ -353,7 +353,7 @@ int send_alarm_checkpoint(const char *msg, size_t msg_len)
 {
     struct send_alarm_checkpoint sac = parse_send_alarm_checkpoint(msg, msg_len);
     if (!sac.node_id || !sac.claim_id) {
-        error("Error parsing SendAlarmCheckpoint");
+        netdata_log_error("Error parsing SendAlarmCheckpoint");
         freez(sac.node_id);
         freez(sac.claim_id);
         return 1;
@@ -368,7 +368,7 @@ int send_alarm_configuration(const char *msg, size_t msg_len)
 {
     char *config_hash = parse_send_alarm_configuration(msg, msg_len);
     if (!config_hash || !*config_hash) {
-        error("Error parsing SendAlarmConfiguration");
+        netdata_log_error("Error parsing SendAlarmConfiguration");
         freez(config_hash);
         return 1;
     }
@@ -381,7 +381,7 @@ int send_alarm_snapshot(const char *msg, size_t msg_len)
 {
     struct send_alarm_snapshot *sas = parse_send_alarm_snapshot(msg, msg_len);
     if (!sas->node_id || !sas->claim_id || !sas->snapshot_uuid) {
-        error("Error parsing SendAlarmSnapshot");
+        netdata_log_error("Error parsing SendAlarmSnapshot");
         destroy_send_alarm_snapshot(sas);
         return 1;
     }
@@ -396,7 +396,7 @@ int handle_disconnect_req(const char *msg, size_t msg_len)
     if (!cmd)
         return 1;
     if (cmd->permaban) {
-        error("Cloud Banned This Agent!");
+        netdata_log_error("Cloud Banned This Agent!");
         aclk_disable_runtime = 1;
     }
     netdata_log_info("Cloud requested disconnect (EC=%u, \"%s\")", (unsigned int)cmd->error_code, cmd->error_description);
@@ -531,7 +531,7 @@ void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t
     new_cloud_rx_msg_t *msg_descriptor = find_rx_handler_by_hash(simple_hash(message_type));
     debug(D_ACLK, "Got message named '%s' from cloud", message_type);
     if (unlikely(!msg_descriptor)) {
-        error("Do not know how to handle message of type '%s'. Ignoring", message_type);
+        netdata_log_error("Do not know how to handle message of type '%s'. Ignoring", message_type);
         if (aclk_stats_enabled) {
             ACLK_STATS_LOCK;
             aclk_metrics_per_sample.cloud_req_err++;
@@ -557,7 +557,7 @@ void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t
         ACLK_STATS_UNLOCK;
     }
     if (msg_descriptor->fnc(msg, msg_len)) {
-        error("Error processing message of type '%s'", message_type);
+        netdata_log_error("Error processing message of type '%s'", message_type);
         if (aclk_stats_enabled) {
             ACLK_STATS_LOCK;
             aclk_metrics_per_sample.cloud_req_err++;

+ 2 - 2
aclk/aclk_stats.c

@@ -193,7 +193,7 @@ static void aclk_stats_query_threads(uint32_t *queries_per_thread)
 
         for (int i = 0; i < aclk_stats_cfg.query_thread_count; i++) {
             if (snprintfz(dim_name, MAX_DIM_NAME, "Query %d", i) < 0)
-                error("snprintf encoding error");
+                netdata_log_error("snprintf encoding error");
             aclk_qt_data[i].dim = rrddim_add(st, dim_name, NULL, 1, localhost->rrd_update_every, RRD_ALGORITHM_ABSOLUTE);
         }
     }
@@ -463,7 +463,7 @@ void aclk_stats_msg_puback(uint16_t id)
 
     if (unlikely(!pub_time[id])) {
         ACLK_STATS_UNLOCK;
-        error("Received PUBACK for unknown message?!");
+        netdata_log_error("Received PUBACK for unknown message?!");
         return;
     }
 

+ 7 - 7
aclk/aclk_tx_msgs.c

@@ -32,7 +32,7 @@ uint16_t aclk_send_bin_message_subtopic_pid(mqtt_wss_client client, char *msg, s
     const char *topic = aclk_get_topic(subtopic);
 
     if (unlikely(!topic)) {
-        error("Couldn't get topic. Aborting message send.");
+        netdata_log_error("Couldn't get topic. Aborting message send.");
         return 0;
     }
 
@@ -61,7 +61,7 @@ static int aclk_send_message_with_bin_payload(mqtt_wss_client client, json_objec
     int len;
 
     if (unlikely(!topic || topic[0] != '/')) {
-        error ("Full topic required!");
+        netdata_log_error("Full topic required!");
         json_object_put(msg);
         return HTTP_RESP_INTERNAL_SERVER_ERROR;
     }
@@ -172,7 +172,7 @@ void aclk_http_msg_v2_err(mqtt_wss_client client, const char *topic, const char
     json_object_object_add(msg, "error-description", tmp);
 
     if (aclk_send_message_with_bin_payload(client, msg, topic, payload, payload_len)) {
-        error("Failed to send cancellation message for http reply %zu %s", payload_len, payload);
+        netdata_log_error("Failed to send cancellation message for http reply %zu %s", payload_len, payload);
     }
 }
 
@@ -220,7 +220,7 @@ uint16_t aclk_send_agent_connection_update(mqtt_wss_client client, int reachable
 
     rrdhost_aclk_state_lock(localhost);
     if (unlikely(!localhost->aclk_state.claimed_id)) {
-        error("Internal error. Should not come here if not claimed");
+        netdata_log_error("Internal error. Should not come here if not claimed");
         rrdhost_aclk_state_unlock(localhost);
         return 0;
     }
@@ -233,7 +233,7 @@ uint16_t aclk_send_agent_connection_update(mqtt_wss_client client, int reachable
     rrdhost_aclk_state_unlock(localhost);
 
     if (!msg) {
-        error("Error generating agent::v1::UpdateAgentConnection payload");
+        netdata_log_error("Error generating agent::v1::UpdateAgentConnection payload");
         return 0;
     }
 
@@ -255,7 +255,7 @@ char *aclk_generate_lwt(size_t *size) {
 
     rrdhost_aclk_state_lock(localhost);
     if (unlikely(!localhost->aclk_state.claimed_id)) {
-        error("Internal error. Should not come here if not claimed");
+        netdata_log_error("Internal error. Should not come here if not claimed");
         rrdhost_aclk_state_unlock(localhost);
         return NULL;
     }
@@ -265,7 +265,7 @@ char *aclk_generate_lwt(size_t *size) {
     rrdhost_aclk_state_unlock(localhost);
 
     if (!msg)
-        error("Error generating agent::v1::UpdateAgentConnection payload for LWT");
+        netdata_log_error("Error generating agent::v1::UpdateAgentConnection payload for LWT");
 
     return msg;
 }

+ 12 - 12
aclk/aclk_util.c

@@ -185,7 +185,7 @@ static void topic_generate_final(struct aclk_topic *t) {
 
     rrdhost_aclk_state_lock(localhost);
     if (unlikely(!localhost->aclk_state.claimed_id)) {
-        error("This should never be called if agent not claimed");
+        netdata_log_error("This should never be called if agent not claimed");
         rrdhost_aclk_state_unlock(localhost);
         return;
     }
@@ -214,7 +214,7 @@ static int topic_cache_add_topic(struct json_object *json, struct aclk_topic *to
     while (!json_object_iter_equal(&it, &itEnd)) {
         if (!strcmp(json_object_iter_peek_name(&it), JSON_TOPIC_KEY_NAME)) {
             if (json_object_get_type(json_object_iter_peek_value(&it)) != json_type_string) {
-                error("topic dictionary key \"" JSON_TOPIC_KEY_NAME "\" is expected to be json_type_string");
+                netdata_log_error("topic dictionary key \"" JSON_TOPIC_KEY_NAME "\" is expected to be json_type_string");
                 return 1;
             }
             topic->topic_id = topic_name_to_id(json_object_get_string(json_object_iter_peek_value(&it)));
@@ -226,7 +226,7 @@ static int topic_cache_add_topic(struct json_object *json, struct aclk_topic *to
         }
         if (!strcmp(json_object_iter_peek_name(&it), JSON_TOPIC_KEY_TOPIC)) {
             if (json_object_get_type(json_object_iter_peek_value(&it)) != json_type_string) {
-                error("topic dictionary key \"" JSON_TOPIC_KEY_TOPIC "\" is expected to be json_type_string");
+                netdata_log_error("topic dictionary key \"" JSON_TOPIC_KEY_TOPIC "\" is expected to be json_type_string");
                 return 1;
             }
             topic->topic_recvd = strdupz(json_object_get_string(json_object_iter_peek_value(&it)));
@@ -234,12 +234,12 @@ static int topic_cache_add_topic(struct json_object *json, struct aclk_topic *to
             continue;
         }
 
-        error("topic dictionary has Unknown/Unexpected key \"%s\" in topic description. Ignoring!", json_object_iter_peek_name(&it));
+        netdata_log_error("topic dictionary has Unknown/Unexpected key \"%s\" in topic description. Ignoring!", json_object_iter_peek_name(&it));
         json_object_iter_next(&it);
     }
 
     if (!topic->topic_recvd) {
-        error("topic dictionary Missig compulsory key %s", JSON_TOPIC_KEY_TOPIC);
+        netdata_log_error("topic dictionary Missig compulsory key %s", JSON_TOPIC_KEY_TOPIC);
         return 1;
     }
 
@@ -255,7 +255,7 @@ int aclk_generate_topic_cache(struct json_object *json)
 
     size_t array_size = json_object_array_length(json);
     if (!array_size) {
-        error("Empty topic list!");
+        netdata_log_error("Empty topic list!");
         return 1;
     }
 
@@ -267,19 +267,19 @@ int aclk_generate_topic_cache(struct json_object *json)
     for (size_t i = 0; i < array_size; i++) {
         obj = json_object_array_get_idx(json, i);
         if (json_object_get_type(obj) != json_type_object) {
-            error("expected json_type_object");
+            netdata_log_error("expected json_type_object");
             return 1;
         }
         aclk_topic_cache[i] = callocz(1, sizeof(struct aclk_topic));
         if (topic_cache_add_topic(obj, aclk_topic_cache[i])) {
-            error("failed to parse topic @idx=%d", (int)i);
+            netdata_log_error("failed to parse topic @idx=%d", (int)i);
             return 1;
         }
     }
 
     for (int i = 0; compulsory_topics[i] != ACLK_TOPICID_UNKNOWN; i++) {
         if (!aclk_get_topic(compulsory_topics[i])) {
-            error("missing compulsory topic \"%s\" in password response from cloud", topic_id_to_name(compulsory_topics[i]));
+            netdata_log_error("missing compulsory topic \"%s\" in password response from cloud", topic_id_to_name(compulsory_topics[i]));
             return 1;
         }
     }
@@ -295,7 +295,7 @@ int aclk_generate_topic_cache(struct json_object *json)
 const char *aclk_get_topic(enum aclk_topics topic)
 {
     if (!aclk_topic_cache) {
-        error("Topic cache not initialized");
+        netdata_log_error("Topic cache not initialized");
         return NULL;
     }
 
@@ -303,7 +303,7 @@ const char *aclk_get_topic(enum aclk_topics topic)
         if (aclk_topic_cache[i]->topic_id == topic)
             return aclk_topic_cache[i]->topic;
     }
-    error("Unknown topic");
+    netdata_log_error("Unknown topic");
     return NULL;
 }
 
@@ -315,7 +315,7 @@ const char *aclk_get_topic(enum aclk_topics topic)
 const char *aclk_topic_cache_iterate(aclk_topic_cache_iter_t *iter)
 {
     if (!aclk_topic_cache) {
-        error("Topic cache not initialized when %s was called.", __FUNCTION__);
+        netdata_log_error("Topic cache not initialized when %s was called.", __FUNCTION__);
         return NULL;
     }
 

Some files were not shown because too many files changed in this diff