MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / suspend_progress_bar

Function suspend_progress_bar

src/local_logger/mod.rs:51–64  ·  view source on GitHub ↗

Hide the progress bar temporarily, execute `f`, then redraw the progress bar. If the output is not a TTY, `f` will be executed without hiding the progress bar.

(f: F)

Source from the content-addressed store, hash-verified

49///
50/// If the output is not a TTY, `f` will be executed without hiding the progress bar.
51pub fn suspend_progress_bar<F: FnOnce() -> R, R>(f: F) -> R {
52 // If the output is a TTY, and there is a spinner, suspend it
53 if *IS_TTY {
54 // Use try_lock to avoid deadlock on reentrant calls
55 if let Ok(mut spinner) = SPINNER.try_lock() {
56 if let Some(spinner) = spinner.as_mut() {
57 return spinner.suspend(f);
58 }
59 }
60 }
61
62 // Otherwise, just run the function
63 f()
64}
65
66pub struct LocalLogger {
67 log_level: log::LevelFilter,

Callers 3

validate_sudo_accessFunction · 0.85
logMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected