surrealcs_kernel/logging/messages/actors_client/
router.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Defines the logging of transaction messages sent to the client router.
use crate::logging::messages::connections::ping::PingJourney;
use crate::logging::messages::transactions::base::TransactionJourney;
use crate::messages::client::message::TransactionMessage;
use crate::messages::server::interface::ServerMessage;

const TARGET: &str = "surrealcs::kernel::client::router";

/// Logs a transaction message that the client router has received.
///
/// # Arguments
/// * `message`: the transaction message that the client router has received
pub fn log_client_router_message(message: &TransactionMessage) {
	if let TransactionMessage::TransactionOperation(unwrapped_message) = message {
		// Log ping messages separately
		if let ServerMessage::Ping(_) = unwrapped_message.message {
			tracing::trace!(target: TARGET, connection_id = %unwrapped_message.connection_id,
				"{}",
				PingJourney::RecievedByClientRouter.as_str()
			);
		}
		// Log other transaction messages
		let tx_pointer = TransactionJourney::RecievedByClientRouter;
		let log = tx_pointer.from_wrapped_server_message(unwrapped_message);
		if let Some(log) = log {
			tracing::trace!(target: TARGET, "{log}");
		}
	}
}