//! Defines the logging of transaction messages sent to the server writer.
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;

/// Logs a transaction message that the server writer has received.
///
/// # Arguments
/// * `message`: the transaction message that the server writer has received
pub fn log_server_writer_message(message: &WrappedServerMessage) {
	if let ServerMessage::Ping(_) = message.message {
		tracing::trace!("{}", PingJourney::RecievedByServerWriter.to_log(&message.connection_id));
	}
	let tx_pointer = TransactionJourney::RecievedByServerWriter;
	let log = tx_pointer.from_wrapped_server_message(message);
	if log.is_some() {
		tracing::trace!("{}", log.unwrap());
	}
}
