v0.7.4 - Remove excessive debug logging from entire codebase - preserve user-facing error logging
This commit is contained in:
@@ -157,9 +157,6 @@ int process_dm_admin_command(cJSON* command_array, cJSON* event, char* error_mes
|
||||
}
|
||||
|
||||
const char* command_type = cJSON_GetStringValue(command_item);
|
||||
log_info("DM Admin: Processing command");
|
||||
printf(" Command: %s\n", command_type);
|
||||
printf(" Parameters: %d\n", array_size - 1);
|
||||
|
||||
// Create synthetic tags from the command array for unified handler compatibility
|
||||
cJSON* synthetic_tags = cJSON_CreateArray();
|
||||
@@ -214,7 +211,6 @@ int process_dm_admin_command(cJSON* command_array, cJSON* event, char* error_mes
|
||||
log_error("DM Admin: Missing auth_query type parameter");
|
||||
snprintf(error_message, error_size, "invalid: missing auth_query type");
|
||||
} else {
|
||||
printf(" Query type: %s\n", query_type);
|
||||
result = handle_auth_query_unified(event, query_type, error_message, error_size, wsi);
|
||||
}
|
||||
}
|
||||
@@ -224,7 +220,6 @@ int process_dm_admin_command(cJSON* command_array, cJSON* event, char* error_mes
|
||||
log_error("DM Admin: Missing config_query type parameter");
|
||||
snprintf(error_message, error_size, "invalid: missing config_query type");
|
||||
} else {
|
||||
printf(" Query type: %s\n", query_type);
|
||||
result = handle_config_query_unified(event, query_type, error_message, error_size, wsi);
|
||||
}
|
||||
}
|
||||
@@ -235,7 +230,6 @@ int process_dm_admin_command(cJSON* command_array, cJSON* event, char* error_mes
|
||||
log_error("DM Admin: Missing config_set parameters");
|
||||
snprintf(error_message, error_size, "invalid: missing config_set key or value");
|
||||
} else {
|
||||
printf(" Key: %s, Value: %s\n", config_key, config_value);
|
||||
result = handle_config_set_unified(event, config_key, config_value, error_message, error_size, wsi);
|
||||
}
|
||||
}
|
||||
@@ -248,7 +242,6 @@ int process_dm_admin_command(cJSON* command_array, cJSON* event, char* error_mes
|
||||
log_error("DM Admin: Missing system_command type parameter");
|
||||
snprintf(error_message, error_size, "invalid: missing system_command type");
|
||||
} else {
|
||||
printf(" System command: %s\n", command);
|
||||
result = handle_system_command_unified(event, command, error_message, error_size, wsi);
|
||||
}
|
||||
}
|
||||
@@ -256,7 +249,6 @@ int process_dm_admin_command(cJSON* command_array, cJSON* event, char* error_mes
|
||||
result = handle_stats_query_unified(event, error_message, error_size, wsi);
|
||||
}
|
||||
else if (strcmp(command_type, "whitelist") == 0 || strcmp(command_type, "blacklist") == 0) {
|
||||
printf(" Rule type: %s\n", command_type);
|
||||
result = handle_auth_rule_modification_unified(event, error_message, error_size, wsi);
|
||||
}
|
||||
else {
|
||||
@@ -291,11 +283,6 @@ int parse_config_command(const char* message, char* key, char* value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_info("DEBUG: Parsing config command");
|
||||
char debug_msg[256];
|
||||
snprintf(debug_msg, sizeof(debug_msg), "DEBUG: Input message: '%.100s'", message);
|
||||
log_info(debug_msg);
|
||||
|
||||
// Clean up the message - convert to lowercase and trim
|
||||
char clean_msg[512];
|
||||
size_t msg_len = strlen(message);
|
||||
@@ -408,7 +395,6 @@ int parse_config_command(const char* message, char* key, char* value) {
|
||||
}
|
||||
}
|
||||
|
||||
log_info("DEBUG: No config command pattern matched");
|
||||
return 0; // No pattern matched
|
||||
}
|
||||
|
||||
@@ -603,7 +589,6 @@ void cleanup_expired_pending_changes(void) {
|
||||
// Apply a configuration change to the database
|
||||
int apply_config_change(const char* key, const char* value) {
|
||||
if (!key || !value) {
|
||||
log_error("DEBUG: apply_config_change called with NULL key or value");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -613,11 +598,6 @@ int apply_config_change(const char* key, const char* value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_info("DEBUG: Applying config change");
|
||||
char debug_msg[256];
|
||||
snprintf(debug_msg, sizeof(debug_msg), "DEBUG: Key='%s', Value='%s'", key, value);
|
||||
log_info(debug_msg);
|
||||
|
||||
// Normalize boolean values
|
||||
char normalized_value[256];
|
||||
strncpy(normalized_value, value, sizeof(normalized_value) - 1);
|
||||
@@ -630,11 +610,6 @@ int apply_config_change(const char* key, const char* value) {
|
||||
strcpy(normalized_value, "false");
|
||||
}
|
||||
|
||||
log_info("DEBUG: Normalized value");
|
||||
char norm_msg[256];
|
||||
snprintf(norm_msg, sizeof(norm_msg), "DEBUG: Normalized value='%s'", normalized_value);
|
||||
log_info(norm_msg);
|
||||
|
||||
// Determine the data type based on the configuration key
|
||||
const char* data_type = "string"; // Default to string
|
||||
for (int i = 0; known_configs[i].key != NULL; i++) {
|
||||
@@ -654,7 +629,6 @@ int apply_config_change(const char* key, const char* value) {
|
||||
sqlite3_stmt* stmt;
|
||||
const char* sql = "INSERT OR REPLACE INTO config (key, value, data_type) VALUES (?, ?, ?)";
|
||||
|
||||
log_info("DEBUG: Preparing SQL statement");
|
||||
if (sqlite3_prepare_v2(g_db, sql, -1, &stmt, NULL) != SQLITE_OK) {
|
||||
log_error("Failed to prepare config update statement");
|
||||
const char* err_msg = sqlite3_errmsg(g_db);
|
||||
@@ -662,12 +636,10 @@ int apply_config_change(const char* key, const char* value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_info("DEBUG: Binding parameters");
|
||||
sqlite3_bind_text(stmt, 1, key, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_text(stmt, 2, normalized_value, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_text(stmt, 3, data_type, -1, SQLITE_STATIC);
|
||||
|
||||
log_info("DEBUG: Executing SQL statement");
|
||||
int result = sqlite3_step(stmt);
|
||||
if (result != SQLITE_DONE) {
|
||||
log_error("Failed to update configuration in database");
|
||||
@@ -678,8 +650,6 @@ int apply_config_change(const char* key, const char* value) {
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
log_info("DEBUG: SQL execution successful");
|
||||
char log_msg[512];
|
||||
snprintf(log_msg, sizeof(log_msg), "Configuration updated: %s = %s", key, normalized_value);
|
||||
log_success(log_msg);
|
||||
@@ -784,11 +754,9 @@ int handle_config_confirmation(const char* admin_pubkey, const char* response) {
|
||||
|
||||
if (is_yes) {
|
||||
// Apply the configuration change
|
||||
log_info("DEBUG: Applying configuration change");
|
||||
int result = apply_config_change(change->config_key, change->new_value);
|
||||
if (result == 0) {
|
||||
// Send success response
|
||||
log_info("DEBUG: Configuration change applied successfully, sending success response");
|
||||
char success_msg[1024];
|
||||
snprintf(success_msg, sizeof(success_msg),
|
||||
"✅ Configuration Updated\n"
|
||||
@@ -803,10 +771,7 @@ int handle_config_confirmation(const char* admin_pubkey, const char* response) {
|
||||
char error_msg[256];
|
||||
int send_result = send_nip17_response(admin_pubkey, success_msg, error_msg, sizeof(error_msg));
|
||||
if (send_result != 0) {
|
||||
log_error("DEBUG: Failed to send success response");
|
||||
log_error(error_msg);
|
||||
} else {
|
||||
log_success("DEBUG: Success response sent");
|
||||
}
|
||||
|
||||
// Remove the pending change
|
||||
@@ -814,7 +779,6 @@ int handle_config_confirmation(const char* admin_pubkey, const char* response) {
|
||||
return 1; // Success
|
||||
} else {
|
||||
// Send error response
|
||||
log_error("DEBUG: Configuration change failed, sending error response");
|
||||
char error_msg[1024];
|
||||
snprintf(error_msg, sizeof(error_msg),
|
||||
"❌ Configuration Update Failed\n"
|
||||
@@ -829,10 +793,7 @@ int handle_config_confirmation(const char* admin_pubkey, const char* response) {
|
||||
char send_error_msg[256];
|
||||
int send_result = send_nip17_response(admin_pubkey, error_msg, send_error_msg, sizeof(send_error_msg));
|
||||
if (send_result != 0) {
|
||||
log_error("DEBUG: Failed to send error response");
|
||||
log_error(send_error_msg);
|
||||
} else {
|
||||
log_success("DEBUG: Error response sent");
|
||||
}
|
||||
|
||||
// Remove the pending change
|
||||
@@ -929,21 +890,14 @@ int process_config_change_request(const char* admin_pubkey, const char* message)
|
||||
}
|
||||
|
||||
// Generate and send confirmation message
|
||||
log_info("DEBUG: Generating confirmation message");
|
||||
char* confirmation = generate_config_change_confirmation(key, current_value, value);
|
||||
if (confirmation) {
|
||||
log_info("DEBUG: Confirmation message generated, sending response");
|
||||
char error_msg[256];
|
||||
int send_result = send_nip17_response(admin_pubkey, confirmation, error_msg, sizeof(error_msg));
|
||||
if (send_result == 0) {
|
||||
log_success("DEBUG: Confirmation response sent successfully");
|
||||
} else {
|
||||
log_error("DEBUG: Failed to send confirmation response");
|
||||
if (send_result != 0) {
|
||||
log_error(error_msg);
|
||||
}
|
||||
free(confirmation);
|
||||
} else {
|
||||
log_error("DEBUG: Failed to generate confirmation message");
|
||||
}
|
||||
|
||||
free(change_id);
|
||||
|
||||
Reference in New Issue
Block a user