Add connection_verbose setting to log IO events (#774)

This commit is contained in:
Sean McArthur
2020-01-09 13:42:01 -08:00
committed by GitHub
parent 20d50daa8b
commit 50c33a932e
6 changed files with 209 additions and 54 deletions

View File

@@ -64,6 +64,7 @@ struct Config {
#[cfg(feature = "__tls")]
certs_verification: bool,
connect_timeout: Option<Duration>,
connection_verbose: bool,
max_idle_per_host: usize,
#[cfg(feature = "__tls")]
identity: Option<Identity>,
@@ -111,6 +112,7 @@ impl ClientBuilder {
#[cfg(feature = "__tls")]
certs_verification: true,
connect_timeout: None,
connection_verbose: false,
max_idle_per_host: std::usize::MAX,
proxies: Vec::new(),
auto_sys_proxy: true,
@@ -234,6 +236,7 @@ impl ClientBuilder {
};
connector.set_timeout(config.connect_timeout);
connector.set_verbose(config.connection_verbose);
let mut builder = hyper::Client::builder();
if config.http2_only {
@@ -489,6 +492,17 @@ impl ClientBuilder {
self
}
/// Set whether connections should emit verbose logs.
///
/// Enabling this option will emit [log][] messages at the `TRACE` level
/// for read and write operations on connections.
///
/// [log]: https://crates.io/crates/log
pub fn connection_verbose(mut self, verbose: bool) -> ClientBuilder {
self.config.connection_verbose = verbose;
self
}
// HTTP options
/// Sets the maximum idle connection per host allowed in the pool.