Move request/response debug logging to client

This commit is contained in:
Nicholas Rempel 2022-03-10 15:34:47 -08:00 committed by masalachai
parent ace791b521
commit dd3c60f50e
2 changed files with 7 additions and 4 deletions

View File

@ -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<C: Connector> EppClient<C> {
})
}
/// 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<Greeting, Error> {
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<C: Connector> EppClient<C> {
let epp_xml =
<Cmd as Transaction<Ext>>::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),

View File

@ -15,7 +15,7 @@ use crate::error::Error;
/// EPP Connection struct with some metadata for the connection
pub(crate) struct EppConnection<C: Connector> {
registry: String,
pub registry: String,
connector: C,
stream: C::Connection,
pub greeting: String,
@ -74,7 +74,6 @@ impl<C: Connector> EppConnection<C> {
/// Sends an EPP XML request to the registry and returns the response
pub(crate) fn transact<'a>(&'a mut self, command: &str) -> Result<RequestFuture<'a, C>, Error> {
debug!("{}: request: {}", self.registry, command);
let new = RequestState::new(command)?;
// If we have a request currently in flight, finish that first