From dd3c60f50ef5f01aee3f784b14d7ac1c9cded51f Mon Sep 17 00:00:00 2001 From: Nicholas Rempel Date: Thu, 10 Mar 2022 15:34:47 -0800 Subject: [PATCH] Move request/response debug logging to client --- src/client.rs | 8 ++++++-- src/connection.rs | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client.rs b/src/client.rs index 99c64a3..fadf637 100644 --- a/src/client.rs +++ b/src/client.rs @@ -12,7 +12,7 @@ use tokio_rustls::client::TlsStream; use tokio_rustls::rustls::{ClientConfig, OwnedTrustAnchor, RootCertStore, ServerName}; #[cfg(feature = "tokio-rustls")] use tokio_rustls::TlsConnector; -use tracing::{error, info}; +use tracing::{debug, error, info}; use crate::common::{Certificate, NoExtension, PrivateKey}; pub use crate::connection::Connector; @@ -105,11 +105,13 @@ impl EppClient { }) } - /// Executes an EPP Hello call and returns the response as an `Greeting` + /// Executes an EPP Hello call and returns the response as a `Greeting` pub async fn hello(&mut self) -> Result { let hello_xml = HelloDocument::default().serialize()?; + debug!("{}: hello: {}", self.connection.registry, &hello_xml); let response = self.connection.transact(&hello_xml)?.await?; + debug!("{}: greeting: {}", self.connection.registry, &response); Ok(GreetingDocument::deserialize(&response)?.data) } @@ -127,7 +129,9 @@ impl EppClient { let epp_xml = >::serialize_request(data.command, data.extension, id)?; + debug!("{}: request: {}", self.connection.registry, &epp_xml); let response = self.connection.transact(&epp_xml)?.await?; + debug!("{}: response: {}", self.connection.registry, &response); match Cmd::deserialize_response(&response) { Ok(response) => Ok(response), diff --git a/src/connection.rs b/src/connection.rs index ae0eb6a..4a91b0f 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -15,7 +15,7 @@ use crate::error::Error; /// EPP Connection struct with some metadata for the connection pub(crate) struct EppConnection { - registry: String, + pub registry: String, connector: C, stream: C::Connection, pub greeting: String, @@ -74,7 +74,6 @@ impl EppConnection { /// Sends an EPP XML request to the registry and returns the response pub(crate) fn transact<'a>(&'a mut self, command: &str) -> Result, Error> { - debug!("{}: request: {}", self.registry, command); let new = RequestState::new(command)?; // If we have a request currently in flight, finish that first