Skip to content

Commit

Permalink
feat: Use JJ_LOG instead of RUST_LOG for tracing configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
theduke committed Aug 27, 2024
1 parent 44ed245 commit aa606b2
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 @@ -189,11 +189,14 @@ pub struct TracingSubscription {
}

impl TracingSubscription {
const ENV_VAR_NAME: &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 @@ -244,6 +247,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 aa606b2

Please sign in to comment.