Browse Source

Enable aclk conversation log even without NETDATA_INTERNAL CHECKS (#13917)

enable aclk conversation without INTERNAL CHECKS
Emmanuel Vasilakis 2 years ago
parent
commit
cd28c68615
2 changed files with 16 additions and 12 deletions
  1. 10 9
      aclk/aclk_rx_msgs.c
  2. 6 3
      aclk/aclk_tx_msgs.c

+ 10 - 9
aclk/aclk_rx_msgs.c

@@ -527,15 +527,16 @@ void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t
         return;
     }
 
-#ifdef NETDATA_INTERNAL_CHECKS
-    if (!strncmp(message_type, "cmd", strlen("cmd"))) {
-        log_aclk_message_bin(msg, msg_len, 0, topic, msg_descriptor->name);
-    } else {
-        char *json = protomsg_to_json(msg, msg_len, msg_descriptor->name);
-        log_aclk_message_bin(json, strlen(json), 0, topic, msg_descriptor->name);
-        freez(json);
-    }
-#endif
+
+    if (aclklog_enabled) {
+        if (!strncmp(message_type, "cmd", strlen("cmd"))) {
+            log_aclk_message_bin(msg, msg_len, 0, topic, msg_descriptor->name);
+        } else {
+            char *json = protomsg_to_json(msg, msg_len, msg_descriptor->name);
+            log_aclk_message_bin(json, strlen(json), 0, topic, msg_descriptor->name);
+            freez(json);
+        }
+    }
 
     if (aclk_stats_enabled) {
         ACLK_STATS_LOCK;

+ 6 - 3
aclk/aclk_tx_msgs.c

@@ -39,11 +39,14 @@ uint16_t aclk_send_bin_message_subtopic_pid(mqtt_wss_client client, char *msg, s
 
 #ifdef NETDATA_INTERNAL_CHECKS
     aclk_stats_msg_published(packet_id);
-    char *json = protomsg_to_json(msg, msg_len, msgname);
-    log_aclk_message_bin(json, strlen(json), 1, topic, msgname);
-    freez(json);
 #endif
 
+    if (aclklog_enabled) {
+        char *json = protomsg_to_json(msg, msg_len, msgname);
+        log_aclk_message_bin(json, strlen(json), 1, topic, msgname);
+        freez(json);
+    }
+
     return packet_id;
 }