mtlog-progress
A progress bar implementation that works gracefully with mtlog's logger. Multiple progress bars can run concurrently across multiple threads or tasks while staying in place when intermingled with regular logs.
Related Crates
This crate requires a logger from the mtlog family:
mtlog- Use with standard multi-threaded applicationsmtlog-tokio- Use with async tokio applications
Installation
Add this to your Cargo.toml:
[]
= "0.2"
= "0.2" # or mtlog-tokio for async
Iterator Progress Tracking
The easiest way to add progress tracking is using the .progress() method on iterators:
use logger_config;
use ProgressIteratorExt;
let _guard = logger_config.init_global;
// For ExactSizeIterator - automatically detects length
.progress
.for_each;
// For any iterator - provide length manually
vec!
.into_iter
.progress_with
.map
.;
// With custom configuration
.progress
.with_min_timestep_ms
.with_min_percentage_change
.for_each;
The progress bar automatically finishes when the iterator is exhausted or dropped.
Manual Progress Bar Usage
For more control, you can manually create and update progress bars:
With std threads
use logger_config;
use LogProgressBar;
let _guard = logger_config
.init_global;
let h = spawn;
info!;
h.join.unwrap;
With tokio tasks
[]
= "0.2"
= "0.2"
= { = "1", = ["full"] }
use logger_config;
use LogProgressBar;
async
Configuring Update Behavior
You can control how often the progress bar updates to reduce performance overhead:
use LogProgressBar;
let pb = new
.with_min_timestep_ms // Update at most every 200ms
.with_min_percentage_change; // Update at least every 1%
for _ in 0..1000000
pb.finish;
Documentation
For detailed API documentation, visit docs.rs/mtlog-progress.
License
MIT