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)
| 49 | /// |
| 50 | /// If the output is not a TTY, `f` will be executed without hiding the progress bar. |
| 51 | pub 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 | |
| 66 | pub struct LocalLogger { |
| 67 | log_level: log::LevelFilter, |
no outgoing calls
no test coverage detected