surrealcs_kernel/logging/messages/actors_client/
writer.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
//! Defines the logging of transaction messages sent to the client writer.
use crate::logging::messages::connections::ping::PingJourney;
use crate::logging::messages::transactions::base::TransactionJourney;
use crate::messages::client::message::TransactionMessage;

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

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