Skip to content

Commit 2f415b0

Browse files
reivilibresandhose
authored andcommitted
Add progress bars to syn2mas
1 parent 84587e5 commit 2f415b0

File tree

8 files changed

+264
-20
lines changed

8 files changed

+264
-20
lines changed

Cargo.lock

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ version = "0.1.41"
365365
[workspace.dependencies.tracing-subscriber]
366366
version = "0.3.19"
367367

368+
# Progress bars
369+
[workspace.dependencies.tracing-indicatif]
370+
version = "0.3.9"
371+
368372
# OpenTelemetry
369373
[workspace.dependencies.opentelemetry]
370374
version = "0.28.0"

crates/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ tracing.workspace = true
5151
tracing-appender = "0.2.3"
5252
tracing-subscriber = { workspace = true, features = ["env-filter"] }
5353
tracing-opentelemetry.workspace = true
54+
tracing-indicatif.workspace = true
5455
opentelemetry.workspace = true
5556
opentelemetry-http.workspace = true
5657
opentelemetry-jaeger-propagator.workspace = true

crates/cli/src/commands/syn2mas.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ impl Options {
232232
#[allow(clippy::disallowed_methods)]
233233
let mut rng = thread_rng();
234234

235-
// TODO progress reporting
236235
let mas_matrix = MatrixConfig::extract(figment)?;
237236
syn2mas::migrate(
238237
reader,

crates/cli/src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ use anyhow::Context;
1212
use clap::Parser;
1313
use mas_config::{ConfigurationSection, TelemetryConfig};
1414
use sentry_tracing::EventFilter;
15+
use tracing_indicatif::{
16+
IndicatifLayer,
17+
filter::{IndicatifFilter, hide_indicatif_span_fields},
18+
};
1519
use tracing_subscriber::{
16-
EnvFilter, Layer, Registry, filter::LevelFilter, layer::SubscriberExt, util::SubscriberInitExt,
20+
EnvFilter, Layer, Registry, filter::LevelFilter, fmt::format::DefaultFields,
21+
layer::SubscriberExt, util::SubscriberInitExt,
1722
};
1823

1924
mod app_state;
@@ -133,11 +138,17 @@ async fn try_main() -> anyhow::Result<ExitCode> {
133138
.with_filter(LevelFilter::INFO)
134139
});
135140

141+
// Set up progress bars, used in syn2mas for example
142+
let progress_layer = IndicatifLayer::new()
143+
.with_span_field_formatter(hide_indicatif_span_fields(DefaultFields::new()))
144+
.with_filter(IndicatifFilter::new(false));
145+
136146
let subscriber = Registry::default()
137147
.with(sentry_layer)
138148
.with(telemetry_layer)
139149
.with(filter_layer)
140-
.with(fmt_layer);
150+
.with(fmt_layer)
151+
.with(progress_layer);
141152
subscriber
142153
.try_init()
143154
.context("could not initialize logging")?;

crates/syn2mas/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ sqlx.workspace = true
2222
chrono.workspace = true
2323
compact_str.workspace = true
2424
tracing.workspace = true
25+
tracing-indicatif.workspace = true
2526
futures-util = "0.3.31"
2627

2728
rand.workspace = true

0 commit comments

Comments
 (0)