From cd8dca8cd323347a96a6f9c31e7465377e6230d3 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 15 Nov 2023 10:52:38 +0100 Subject: better logging --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 0fb9957..d11bfe1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use crate::{ files::serve_files, proxy::proxy_request, }; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{bail, Context, Result}; use bytes::Bytes; use config::setup_file_watch; use error::ServiceError; @@ -61,9 +61,10 @@ pub type FilterResponse = Option>>; async fn main() -> anyhow::Result<()> { env_logger::init_from_env("LOG"); - let config_path = std::env::args().skip(1).next().ok_or(anyhow!( - "first argument is expected to be the configuration file" - ))?; + let Some(config_path) = std::env::args().skip(1).next() else { + eprintln!("error: first argument is expected to be the configuration file"); + exit(1) + }; let config = match Config::load(&config_path) { Ok(c) => c, @@ -189,6 +190,7 @@ pub async fn serve_stream Ok(r), Err(ServiceError::Hyper(e)) => Err(e), Err(error) => Ok({ + debug!("service error {error:?}"); let mut resp = Response::new(format!( "Sorry, we were unable to process your request: {error}" )); -- cgit v1.2.3-70-g09d2