From 7ea68e6ea875f96e594a3b33688fa222dbda8064 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Sat, 26 Apr 2025 15:21:48 -0500 Subject: [PATCH] feat: MISE_LOG_HTTP --- docs/configuration.md | 4 ++++ src/env.rs | 1 + src/http.rs | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index f031b9c0363..7da7d084073 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -365,6 +365,10 @@ Output logs to a file. Same as `MISE_LOG_LEVEL` but for the log _file_ output level. This is useful if you want to store the logs but not have them litter your display. +### `MISE_LOG_HTTP=1` + +Display HTTP requests/responses in the logs. + ### `MISE_QUIET=1` Equivalent to `MISE_LOG_LEVEL=warn`. diff --git a/src/env.rs b/src/env.rs index da43f8d5938..cb52b7b4952 100644 --- a/src/env.rs +++ b/src/env.rs @@ -153,6 +153,7 @@ pub static ARGV0: Lazy = Lazy::new(|| ARGS.read().unwrap()[0].to_string( pub static MISE_BIN_NAME: Lazy<&str> = Lazy::new(|| filename(&ARGV0)); pub static MISE_LOG_FILE: Lazy> = Lazy::new(|| var_path("MISE_LOG_FILE")); pub static MISE_LOG_FILE_LEVEL: Lazy> = Lazy::new(log_file_level); +pub static MISE_LOG_HTTP: Lazy = Lazy::new(|| var_is_true("MISE_LOG_HTTP")); pub static __USAGE: Lazy> = Lazy::new(|| var("__USAGE").ok()); diff --git a/src/http.rs b/src/http.rs index 14d4c3c7b80..30be7fde7d0 100644 --- a/src/http.rs +++ b/src/http.rs @@ -72,6 +72,9 @@ impl Client { let mut req = self.reqwest.get(url.clone()); req = req.headers(headers.clone()); let resp = req.send().await?; + if *env::MISE_LOG_HTTP { + eprintln!("GET {url} {}", resp.status()); + } debug!("GET {url} {}", resp.status()); display_github_rate_limit(&resp); resp.error_for_status_ref()?; @@ -113,6 +116,9 @@ impl Client { let mut req = self.reqwest.head(url.clone()); req = req.headers(headers.clone()); let resp = req.send().await?; + if *env::MISE_LOG_HTTP { + eprintln!("HEAD {url} {}", resp.status()); + } debug!("HEAD {url} {}", resp.status()); display_github_rate_limit(&resp); resp.error_for_status_ref()?;