Enhance command processing with detailed debug logging

Added comprehensive debug logging to the `process_text_command` function, providing insights into raw command payloads, parsed command types, and error details when debugging is enabled. This update improves troubleshooting capabilities by offering clearer visibility into command handling and potential parsing issues.
This commit is contained in:
Torsten Schulz (local)
2026-03-27 13:49:27 +01:00
parent 16d71a8c1c
commit 2bf7823f21

View File

@@ -21,11 +21,30 @@ pub async fn process_text_command(
if trimmed.is_empty() {
return;
}
if room_debug_enabled() {
eprintln!(
"[yourchat2][room-debug][raw] client_id={client_id} payload={}",
trimmed
);
}
match serde_json::from_str::<Command>(trimmed) {
Ok(command) => {
if room_debug_enabled() {
let command_type = command_name(&command);
eprintln!(
"[yourchat2][room-debug][parsed] client_id={client_id} type='{}' room={:?} name={:?}",
command_type, command.room, command.name
);
}
handle_command(client_id, command, state, config).await;
}
Err(err) => {
if room_debug_enabled() {
eprintln!(
"[yourchat2][room-debug][parse-error] client_id={client_id} error='{}' payload={}",
err, trimmed
);
}
state::send_to_client(
client_id,
state,