diff --git a/src/main.rs b/src/main.rs index d40346c..6faf732 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,7 +73,7 @@ fn main() { panic!("Failed to listen on {addr}: {e}") } else { // already listening on the other unspecified address - log::warn!("Could not start listener on {}, but already listening on another unspecified address. Probably your system automatically listens in dual stack?", addr); + log::warn!("Could not start listener on {addr}, but already listening on another unspecified address. Probably your system automatically listens in dual stack?"); continue; } } @@ -82,7 +82,7 @@ fn main() { listening_unspecified |= addr.ip().is_unspecified(); handles.push(tokio::spawn(async move { - log::info!("Started listener on {}", addr); + log::info!("Started listener on {addr}"); loop { let (stream, _) = listener.accept().await.unwrap_or_else(|e| { @@ -92,11 +92,11 @@ fn main() { tokio::spawn(async { match RequestHandle::new(stream, arc).await { Ok(handle) => match handle.handle().await { - Ok(info) => log::info!("{}", info), - Err(err) => log::warn!("{}", err), + Ok(info) => log::info!("{info}"), + Err(err) => log::warn!("{err}"), }, Err(log_line) => { - log::warn!("{}", log_line); + log::warn!("{log_line}"); } } }); @@ -134,11 +134,11 @@ fn main() { tokio::spawn(async { match RequestHandle::new_unix(stream, arc).await { Ok(handle) => match handle.handle().await { - Ok(info) => log::info!("{}", info), - Err(err) => log::warn!("{}", err), + Ok(info) => log::info!("{info}"), + Err(err) => log::warn!("{err}"), }, Err(log_line) => { - log::warn!("{}", log_line); + log::warn!("{log_line}"); } } }); @@ -274,8 +274,7 @@ fn args() -> Result { Err(_) => { // since certificate management should be automated, we are going to create the directory too log::info!( - "The certificate directory {:?} does not exist, creating it.", - certs_path + "The certificate directory {certs_path:?} does not exist, creating it." ); std::fs::create_dir(&certs_path).expect("could not create certificate directory"); // we just created the directory, skip loading from it @@ -295,7 +294,7 @@ fn args() -> Result { // check if we have a certificate for that domain if let Host::Domain(ref domain) = hostname { if !matches!(certs, Some(ref certs) if certs.has_domain(domain)) { - log::info!("No certificate or key found for {:?}, generating them.", s); + log::info!("No certificate or key found for {s:?}, generating them."); let mut cert_params = CertificateParams::new(vec![domain.clone()])?; cert_params @@ -496,7 +495,7 @@ impl RequestHandle { metadata, }), // use nonexistent status code 00 if connection was not established - Err(e) => Err(format!("{} \"\" 00 \"TLS error\" error:{}", log_line, e)), + Err(e) => Err(format!("{log_line} \"\" 00 \"TLS error\" error:{e}")), } } } @@ -743,7 +742,7 @@ where return Ok(()); }; - log::info!("Listing directory {:?}", path); + log::info!("Listing directory {path:?}"); self.send_header(SUCCESS, "text/gemini").await?; self.stream.write_all(preamble.as_bytes()).await?; diff --git a/src/metadata.rs b/src/metadata.rs index 8076d69..34e5d79 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -107,7 +107,7 @@ impl FileOptions { /// (Re)reads a specified sidecar file. /// This function will allways try to read the file, even if it is current. fn read_database(&mut self, db: &Path) { - log::debug!("reading database {:?}", db); + log::debug!("reading database {db:?}"); let mut ini = Ini::new_cs(); ini.set_default_section("mime"); @@ -124,7 +124,7 @@ impl FileOptions { let files = match map { Ok(section) => section, Err(err) => { - log::error!("invalid config file {:?}: {}", db, err); + log::error!("invalid config file {db:?}: {err}"); return; } }; @@ -147,8 +147,7 @@ impl FileOptions { || !header.chars().nth(2).unwrap().is_whitespace() { log::error!( - "Line for {:?} starts like a full header line, but it is incorrect; ignoring it.", - path + "Line for {path:?} starts like a full header line, but it is incorrect; ignoring it." ); return; } @@ -158,9 +157,7 @@ impl FileOptions { // character has to be a space, so correct any // other whitespace to it (e.g. tabs) log::warn!( - "Full Header line for {:?} has an invalid character, treating {:?} as a space.", - path, - separator + "Full Header line for {path:?} has an invalid character, treating {separator:?} as a space." ); } let status = header @@ -193,12 +190,12 @@ impl FileOptions { match glob_with(path, glob_options) { Ok(paths) => paths.collect::>(), Err(err) => { - log::error!("incorrect glob pattern in {:?}: {}", path, err); + log::error!("incorrect glob pattern in {path:?}: {err}"); continue; } } } else { - log::error!("path is not UTF-8: {:?}", path); + log::error!("path is not UTF-8: {path:?}"); continue; }; @@ -213,7 +210,7 @@ impl FileOptions { self.file_meta.insert(path, preset.clone()); } Err(err) => { - log::warn!("could not process glob path: {}", err); + log::warn!("could not process glob path: {err}"); continue; } };