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:
@@ -21,11 +21,30 @@ pub async fn process_text_command(
|
|||||||
if trimmed.is_empty() {
|
if trimmed.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if room_debug_enabled() {
|
||||||
|
eprintln!(
|
||||||
|
"[yourchat2][room-debug][raw] client_id={client_id} payload={}",
|
||||||
|
trimmed
|
||||||
|
);
|
||||||
|
}
|
||||||
match serde_json::from_str::<Command>(trimmed) {
|
match serde_json::from_str::<Command>(trimmed) {
|
||||||
Ok(command) => {
|
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;
|
handle_command(client_id, command, state, config).await;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
if room_debug_enabled() {
|
||||||
|
eprintln!(
|
||||||
|
"[yourchat2][room-debug][parse-error] client_id={client_id} error='{}' payload={}",
|
||||||
|
err, trimmed
|
||||||
|
);
|
||||||
|
}
|
||||||
state::send_to_client(
|
state::send_to_client(
|
||||||
client_id,
|
client_id,
|
||||||
state,
|
state,
|
||||||
|
|||||||
Reference in New Issue
Block a user