Skip to content

Commit 10a765b

Browse files
authored
Merge pull request #343 from tgauth/update-tracing-subscriber-with-indicatif
use tracing indicatif to sync tracing and progress bar rendering
2 parents 7a4b647 + 44ee253 commit 10a765b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

dsc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ sysinfo = { version = "0.29.10" }
2727
thiserror = "1.0.52"
2828
tracing = { version = "0.1.37" }
2929
tracing-subscriber = { version = "0.3.17", features = ["ansi", "env-filter", "json"] }
30+
tracing-indicatif = { version = "0.3.6" }

dsc/src/util.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use syntect::{
3939
};
4040
use tracing::{Level, debug, error, trace};
4141
use tracing_subscriber::{filter::EnvFilter, layer::SubscriberExt, Layer};
42+
use tracing_indicatif::IndicatifLayer;
4243

4344
pub const EXIT_SUCCESS: i32 = 0;
4445
pub const EXIT_INVALID_ARGS: i32 = 1;
@@ -268,7 +269,8 @@ pub fn enable_tracing(trace_level: &TraceLevel, trace_format: &TraceFormat) {
268269
.or_else(|_| EnvFilter::try_new("warning"))
269270
.unwrap_or_default()
270271
.add_directive(tracing_level.into());
271-
let layer = tracing_subscriber::fmt::Layer::default().with_writer(std::io::stderr);
272+
let indicatif_layer = IndicatifLayer::new();
273+
let layer = tracing_subscriber::fmt::Layer::default().with_writer(indicatif_layer.get_stderr_writer());
272274
let fmt = match trace_format {
273275
TraceFormat::Default => {
274276
layer
@@ -294,7 +296,7 @@ pub fn enable_tracing(trace_level: &TraceLevel, trace_format: &TraceFormat) {
294296
}
295297
};
296298

297-
let subscriber = tracing_subscriber::Registry::default().with(fmt).with(filter);
299+
let subscriber = tracing_subscriber::Registry::default().with(fmt).with(filter).with(indicatif_layer);
298300

299301
if tracing::subscriber::set_global_default(subscriber).is_err() {
300302
eprintln!("Unable to set global default tracing subscriber. Tracing is diabled.");

0 commit comments

Comments
 (0)