From 75f00eecb0cf5e0002fe52da94d764fc6cb0e817 Mon Sep 17 00:00:00 2001 From: Chris Veness Date: Sat, 26 Oct 2024 23:12:40 +0100 Subject: fix(cli): Make --watcher CLEAR_SCREEN clear scrollback buffer as well as visible screen (#25997) The --watch option should clear the screen scrollback buffer as well as the screen itself. On Ubuntu (22.04 Jammy) the 'clear' command generates "\x1B[H\x1B[2J\x1B[3J"; that is: - \E[H - cursor home - \E[2J - clear entire screen - \E[3J - clear entire screen & scrollback buffer. By contrast, Deno defined CLEAR_SCREEN as "\x1B[2J\x1B[1;1H", which fails to clear the scrollback buffer. The "\E[H\E[2J\E[3J" sequence works on MacOS (Sonoma) (using printf); I'm not able to test on Windows. Closes https://github.com/denoland/deno/issues/26514 --- cli/util/file_watcher.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cli/util/file_watcher.rs') diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index d92d880bc..8d734af88 100644 --- a/cli/util/file_watcher.rs +++ b/cli/util/file_watcher.rs @@ -30,7 +30,7 @@ use tokio::sync::mpsc; use tokio::sync::mpsc::UnboundedReceiver; use tokio::time::sleep; -const CLEAR_SCREEN: &str = "\x1B[2J\x1B[1;1H"; +const CLEAR_SCREEN: &str = "\x1B[H\x1B[2J\x1B[3J"; const DEBOUNCE_INTERVAL: Duration = Duration::from_millis(200); struct DebouncedReceiver { -- cgit v1.2.3 From 4e899d48cffa95617266dd8f9aef54603a87ad82 Mon Sep 17 00:00:00 2001 From: snek Date: Thu, 14 Nov 2024 13:16:28 +0100 Subject: fix: otel resiliency (#26857) Improving the breadth of collected data, and ensuring that the collected data is more likely to be successfully reported. - Use `log` crate in more places - Hook up `log` crate to otel - Switch to process-wide otel processors - Handle places that use `process::exit` Also adds a more robust testing framework, with a deterministic tracing setting. Refs: https://github.com/denoland/deno/issues/26852 --- cli/util/file_watcher.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'cli/util/file_watcher.rs') diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index 8d734af88..21ea95e06 100644 --- a/cli/util/file_watcher.rs +++ b/cli/util/file_watcher.rs @@ -73,7 +73,6 @@ impl DebouncedReceiver { } } -#[allow(clippy::print_stderr)] async fn error_handler(watch_future: F) -> bool where F: Future>, @@ -84,7 +83,7 @@ where Some(e) => format_js_error(e), None => format!("{err:?}"), }; - eprintln!( + log::error!( "{}: {}", colors::red_bold("error"), error_string.trim_start_matches("error: ") -- cgit v1.2.3 From abf06eb87f10ebed93b39948213dccfe086bd0fa Mon Sep 17 00:00:00 2001 From: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:59:31 +0200 Subject: feat(watch): log which file changed on HMR or watch change (#25801) Closes #25504 --- cli/util/file_watcher.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'cli/util/file_watcher.rs') diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index 21ea95e06..eb3fb8c60 100644 --- a/cli/util/file_watcher.rs +++ b/cli/util/file_watcher.rs @@ -127,19 +127,12 @@ impl PrintConfig { } } -fn create_print_after_restart_fn( - banner: &'static str, - clear_screen: bool, -) -> impl Fn() { +fn create_print_after_restart_fn(clear_screen: bool) -> impl Fn() { move || { #[allow(clippy::print_stderr)] if clear_screen && std::io::stderr().is_terminal() { eprint!("{}", CLEAR_SCREEN); } - info!( - "{} File change detected! Restarting!", - colors::intense_blue(banner), - ); } } @@ -187,7 +180,15 @@ impl WatcherCommunicator { } pub fn print(&self, msg: String) { - log::info!("{} {}", self.banner, msg); + log::info!("{} {}", self.banner, colors::gray(msg)); + } + + pub fn show_path_changed(&self, changed_paths: Option>) { + if let Some(paths) = changed_paths { + self.print( + format!("Restarting! File change detected: {:?}", paths[0]).to_string(), + ) + } } } @@ -263,7 +264,7 @@ where clear_screen, } = print_config; - let print_after_restart = create_print_after_restart_fn(banner, clear_screen); + let print_after_restart = create_print_after_restart_fn(clear_screen); let watcher_communicator = Arc::new(WatcherCommunicator { paths_to_watch_tx: paths_to_watch_tx.clone(), changed_paths_rx: changed_paths_rx.resubscribe(), -- cgit v1.2.3