Logging output improvements

This commit is contained in:
Alex 2021-12-08 11:24:25 +01:00
parent 098a6cf2cd
commit d7f3c13fa4
No known key found for this signature in database
GPG key ID: EDABF9711E244EB1
3 changed files with 20 additions and 4 deletions

View file

@ -63,10 +63,10 @@ pub async fn serve_https(
) )
.await; .await;
if let Err(http_err) = http_result { if let Err(http_err) = http_result {
debug!("HTTP error: {}", http_err); warn!("HTTP error: {}", http_err);
} }
} }
Err(e) => debug!("Error in TLS connection: {}", e), Err(e) => warn!("Error in TLS connection: {}", e),
} }
}); });
} }

View file

@ -57,7 +57,7 @@ struct Opt {
#[tokio::main(flavor = "multi_thread", worker_threads = 10)] #[tokio::main(flavor = "multi_thread", worker_threads = 10)]
async fn main() { async fn main() {
if std::env::var("RUST_LOG").is_err() { if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "tricot=debug") std::env::set_var("RUST_LOG", "tricot=info")
} }
pretty_env_logger::init(); pretty_env_logger::init();
@ -81,7 +81,7 @@ async fn main() {
while rx_proxy_config.changed().await.is_ok() { while rx_proxy_config.changed().await.is_ok() {
info!("Proxy config:"); info!("Proxy config:");
for ent in rx_proxy_config.borrow().entries.iter() { for ent in rx_proxy_config.borrow().entries.iter() {
info!(" {:?}", ent); info!(" {}", ent);
} }
} }
} }

View file

@ -53,6 +53,22 @@ pub struct ProxyEntry {
pub calls: atomic::AtomicU64, pub calls: atomic::AtomicU64,
} }
impl std::fmt::Display for ProxyEntry {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{} ", self.target_addr)?;
match &self.host {
HostDescription::Hostname(h) => write!(f, "{}", h)?,
HostDescription::Pattern(p) => write!(f, "Pattern('{}')", p.as_str())?,
}
write!(f, "{} {}", self.path_prefix.as_ref().unwrap_or(&String::new()), self.priority)?;
if !self.add_headers.is_empty() {
write!(f, "+Headers: {:?}", self.add_headers)?;
}
Ok(())
}
}
#[derive(Debug)] #[derive(Debug)]
pub struct ProxyConfig { pub struct ProxyConfig {
pub entries: Vec<ProxyEntry>, pub entries: Vec<ProxyEntry>,