Skip to content

Commit fb540e5

Browse files
committed
fix: ability to disable tracing subscriber
Signed-off-by: Sam Gammon <[email protected]>
1 parent 89d88d5 commit fb540e5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ term_size = { workspace = true }
6060
thiserror = { workspace = true }
6161
tracing = { workspace = true }
6262
tracing-appender = { workspace = true }
63-
tracing-indicatif = { workspace = true }
63+
tracing-indicatif = { workspace = true, optional = true }
6464
tracing-subscriber = { workspace = true, features = ["env-filter"] }
6565
url = { workspace = true }
6666

@@ -75,10 +75,11 @@ homepage = "https://orogene.dev"
7575
rust-version = "1.85"
7676

7777
[features]
78-
default = ["error-reporting", "mimalloc"]
78+
default = ["error-reporting", "mimalloc", "tracing"]
7979
mimalloc = ["dep:mimalloc"]
8080
error-reporting = ["sentry"]
8181
experimental-simdjson = ["nassun/experimental-simdjson"]
82+
tracing = ["dep:tracing-indicatif"]
8283

8384
[workspace.dependencies]
8485
anyhow = "1.0.96"

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ use kdl::{KdlDocument, KdlNode, KdlValue};
104104
use miette::{IntoDiagnostic, Result};
105105
use oro_config::{OroConfig, OroConfigLayerExt, OroConfigOptions};
106106
use tracing_appender::non_blocking::WorkerGuard;
107-
use tracing_indicatif::IndicatifLayer;
108107
use tracing_subscriber::{
109108
EnvFilter,
110109
filter::{Directive, LevelFilter, Targets},
@@ -113,6 +112,9 @@ use tracing_subscriber::{
113112
};
114113
use url::Url;
115114

115+
#[cfg(feature = "tracing")]
116+
use tracing_indicatif::IndicatifLayer;
117+
116118
use commands::OroCommand;
117119

118120
pub use error::OroError;
@@ -311,6 +313,12 @@ pub struct Orogene {
311313
}
312314

313315
impl Orogene {
316+
#[cfg(not(feature = "tracing"))]
317+
fn setup_logging(&self, _log_file: Option<&Path>) -> Result<Option<WorkerGuard>> {
318+
Ok(None)
319+
}
320+
321+
#[cfg(feature = "tracing")]
314322
fn setup_logging(&self, log_file: Option<&Path>) -> Result<Option<WorkerGuard>> {
315323
let builder = EnvFilter::builder();
316324
let filter = if self.quiet {
@@ -751,6 +759,8 @@ impl Orogene {
751759
.clone()
752760
.or_else(|| config.get::<String>("cache").ok().map(PathBuf::from))
753761
.map(|c| c.join("_logs").join(log_file_name()));
762+
763+
#[cfg(feature = "tracing")]
754764
let _logging_guard = oro.setup_logging(log_file.as_deref())?;
755765
oro.first_time_setup()?;
756766
#[cfg(feature = "error-reporting")]

0 commit comments

Comments
 (0)