surrealcs_kernel/logging/messages/actors_client/
reader.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
//! Defines the logging of transaction messages sent to the client reader.
use crate::logging::messages::connections::ping::PingJourney;
use crate::logging::messages::transactions::base::TransactionJourney;
use crate::messages::server::interface::ServerMessage;
use crate::messages::server::wrapper::WrappedServerMessage;

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

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