Skip to content

Commit

Permalink
cli_util: use JJ_LOG to specify log configuration
Browse files Browse the repository at this point in the history
Using the default `RUST_LOG` env var, conflicts when
working on rust projects.
  • Loading branch information
mrnossiom committed Dec 17, 2024
1 parent 9591523 commit f3a9b6d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,14 @@ pub struct TracingSubscription {
}

impl TracingSubscription {
const ENV_VAR_NAME: &'static str = "JJ_LOG";

/// Initializes tracing with the default configuration. This should be
/// called as early as possible.
pub fn init() -> Self {
let filter = tracing_subscriber::EnvFilter::builder()
.with_default_directive(tracing::metadata::LevelFilter::ERROR.into())
.with_env_var(Self::ENV_VAR_NAME)
.from_env_lossy();
let (filter, reload_log_filter) = tracing_subscriber::reload::Layer::new(filter);

Expand Down Expand Up @@ -267,6 +270,7 @@ impl TracingSubscription {
.modify(|filter| {
*filter = tracing_subscriber::EnvFilter::builder()
.with_default_directive(tracing::metadata::LevelFilter::DEBUG.into())
.with_env_var(Self::ENV_VAR_NAME)
.from_env_lossy();
})
.map_err(|err| internal_error_with_message("failed to enable debug logging", err))?;
Expand Down

0 comments on commit f3a9b6d

Please sign in to comment.