diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2023-07-06 15:46:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-06 15:46:48 +0000 |
commit | e0f388c43f3144abb871cce2a7b44e85a36de48f (patch) | |
tree | cf41e5ae11ae7d0ad5ec0b49f5f4ac4531189eb3 /aclk | |
parent | 3cc220ff5e38ef5cd96a64596c7e0c370d0fa074 (diff) |
Rename generic `error` function (#15296)
Diffstat (limited to 'aclk')
-rw-r--r-- | aclk/aclk.c | 36 | ||||
-rw-r--r-- | aclk/aclk_otp.c | 130 | ||||
-rw-r--r-- | aclk/aclk_proxy.c | 2 | ||||
-rw-r--r-- | aclk/aclk_query.c | 8 | ||||
-rw-r--r-- | aclk/aclk_query_queue.c | 4 | ||||
-rw-r--r-- | aclk/aclk_query_queue.h | 2 | ||||
-rw-r--r-- | aclk/aclk_rx_msgs.c | 32 | ||||
-rw-r--r-- | aclk/aclk_stats.c | 4 | ||||
-rw-r--r-- | aclk/aclk_tx_msgs.c | 14 | ||||
-rw-r--r-- | aclk/aclk_util.c | 24 | ||||
-rw-r--r-- | aclk/https_client.c | 86 | ||||
-rw-r--r-- | aclk/schema-wrappers/alarm_stream.cc | 2 |
12 files changed, 172 insertions, 172 deletions
diff --git a/aclk/aclk.c b/aclk/aclk.c index b7b6a3d81c..4e21b87983 100644 --- a/aclk/aclk.c +++ b/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) { diff --git a/aclk/aclk_otp.c b/aclk/aclk_otp.c index a37c0bb9c2..46d0f6213d 100644 --- a/aclk/aclk_otp.c +++ b/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; diff --git a/aclk/aclk_proxy.c b/aclk/aclk_proxy.c index 1701eb8e85..4af46208f7 100644 --- a/aclk/aclk_proxy.c +++ b/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); } diff --git a/aclk/aclk_query.c b/aclk/aclk_query.c index c640d0b701..a63bf3dc1b 100644 --- a/aclk/aclk_query.c +++ b/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]); diff --git a/aclk/aclk_query_queue.c b/aclk/aclk_query_queue.c index 78a906d962..8ca21d4563 100644 --- a/aclk/aclk_query_queue.c +++ b/aclk/aclk_query_queue.c @@ -27,7 +27,7 @@ static inline int _aclk_queue |