diff --git a/devenv/src/devenv.rs b/devenv/src/devenv.rs index 35ced94d1..464dd2bf4 100644 --- a/devenv/src/devenv.rs +++ b/devenv/src/devenv.rs @@ -192,7 +192,7 @@ impl Devenv { } pub async fn print_dev_env(&mut self, json: bool) -> Result<()> { - let env = self.get_dev_environment(json, false).await?; + let env = self.get_dev_environment(json).await?; print!( "{}", String::from_utf8(env.output).expect("Failed to convert env to utf-8") @@ -223,7 +223,7 @@ impl Devenv { args: &[String], ) -> Result> { self.assemble(false)?; - let env = self.get_dev_environment(false, true).await?; + let env = self.get_dev_environment(false).await?; let mut develop_args = vec![ "develop", @@ -839,13 +839,9 @@ impl Devenv { Ok(()) } - pub async fn get_dev_environment(&mut self, json: bool, logging: bool) -> Result { + pub async fn get_dev_environment(&mut self, json: bool) -> Result { self.assemble(false)?; - if !logging { - log::disable_user_messages(); - } - let gc_root = self.devenv_dot_gc.join("shell"); let span = tracing::info_span!("building_shell", devenv.user_message = "Building shell",); let env = self.nix.dev_env(json, &gc_root).instrument(span).await?; @@ -860,10 +856,6 @@ impl Devenv { ) .expect("Failed to write input-paths.txt"); - if !logging { - log::enable_user_messages(); - } - Ok(DevEnv { output: env.stdout, gc_root, diff --git a/devenv/src/log.rs b/devenv/src/log.rs index 50260e872..985e35c84 100644 --- a/devenv/src/log.rs +++ b/devenv/src/log.rs @@ -192,9 +192,6 @@ use std::sync::atomic::{AtomicBool, Ordering}; #[derive(Default)] pub struct DevenvLayer { - /// Whether to show user messages. - /// Can be dynamically toggled by [enable_user_messages] and [disable_user_messages]. - show_user_messages: AtomicBool, /// Whether the span has an error event. has_error: AtomicBool, } @@ -202,7 +199,6 @@ pub struct DevenvLayer { impl DevenvLayer { pub fn new() -> Self { Self { - show_user_messages: AtomicBool::new(true), has_error: AtomicBool::new(false), } } @@ -240,20 +236,18 @@ where timings: SpanTimings::new(), }); - if self.show_user_messages.load(Ordering::Relaxed) { - with_event_from_span!( - id, - span, - "message" = msg, - "devenv.is_user_message" = true, - "devenv.span_event_kind" = SpanKind::Start as u8, - |event| { - drop(ext); - drop(span); - ctx.event(&event); - } - ); - } + with_event_from_span!( + id, + span, + "message" = msg, + "devenv.is_user_message" = true, + "devenv.span_event_kind" = SpanKind::Start as u8, + |event| { + drop(ext); + drop(span); + ctx.event(&event); + } + ); } } @@ -288,22 +282,20 @@ where let msg = span_ctx.msg.clone(); let time_total = format!("{}", span_ctx.timings.total_duration()); - if self.show_user_messages.load(Ordering::Relaxed) { - with_event_from_span!( - id, - span, - "message" = msg, - "devenv.is_user_message" = true, - "devenv.span_event_kind" = SpanKind::End as u8, - "devenv.span_has_error" = has_error, - "devenv.time_total" = time_total, - |event| { - drop(extensions); - drop(span); - ctx.event(&event); - } - ); - } + with_event_from_span!( + id, + span, + "message" = msg, + "devenv.is_user_message" = true, + "devenv.span_event_kind" = SpanKind::End as u8, + "devenv.span_has_error" = has_error, + "devenv.time_total" = time_total, + |event| { + drop(extensions); + drop(span); + ctx.event(&event); + } + ); } } @@ -315,21 +307,6 @@ where } } -pub fn enable_user_messages() { - set_show_user_messages(true); -} - -pub fn disable_user_messages() { - set_show_user_messages(false); -} - -fn set_show_user_messages(show: bool) { - let dispatcher = tracing::dispatcher::get_default(|dispatcher| dispatcher.clone()); - if let Some(layer) = dispatcher.downcast_ref::() { - layer.show_user_messages.store(show, Ordering::SeqCst); - }; -} - #[derive(Default)] pub struct DevenvFormat { pub verbose: bool,