//! 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;

/// 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 {
		TransactionMessage::Ping((_, connection_id)) => {
			tracing::trace!("{}", PingJourney::RecievedByClientWriter.to_log(connection_id));
		}
		TransactionMessage::TransactionOperation(opetation) => {
			let log =
				TransactionJourney::RecievedByClientWriter.from_wrapped_server_message(opetation);
			if log.is_some() {
				tracing::trace!("{}", log.unwrap());
			}
		}
		_ => {}
	}
}
