surrealcs_kernel/logging/messages/actors_client/
router.rs

1//! Defines the logging of transaction messages sent to the client router.
2use crate::logging::messages::connections::ping::PingJourney;
3use crate::logging::messages::transactions::base::TransactionJourney;
4use crate::messages::client::message::TransactionMessage;
5use crate::messages::server::interface::ServerMessage;
6
7const TARGET: &str = "surrealcs::kernel::client::router";
8
9/// Logs a transaction message that the client router has received.
10///
11/// # Arguments
12/// * `message`: the transaction message that the client router has received
13pub fn log_client_router_message(message: &TransactionMessage) {
14	if let TransactionMessage::TransactionOperation(unwrapped_message) = message {
15		// Log ping messages separately
16		if let ServerMessage::Ping(_) = unwrapped_message.message {
17			tracing::trace!(target: TARGET, connection_id = %unwrapped_message.connection_id,
18				"{}",
19				PingJourney::RecievedByClientRouter.as_str()
20			);
21		}
22		// Log other transaction messages
23		let tx_pointer = TransactionJourney::RecievedByClientRouter;
24		let log = tx_pointer.from_wrapped_server_message(unwrapped_message);
25		if let Some(log) = log {
26			tracing::trace!(target: TARGET, "{log}");
27		}
28	}
29}