Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make logger work while loading config file #581

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

SteveLauC
Copy link
Member

Standards checklist:

  • The PR title is descriptive.
  • I have read CONTRIBUTING.md
  • The code compiles (cargo build)
  • The code passes rustfmt (cargo fmt)
  • The code passes clippy (cargo clippy)
  • The code passes tests (cargo test)
  • Optional: I have tested the code myself

For new steps

  • Optional: Topgrade skips this step where needed
  • Optional: The --dry-run option works with this step
  • Optional: The --yes option works with this step if it is supported by
    the underlying command

If you developed a feature or a bug fix for someone else and you do not have the
means to test it, please tag this person here.

What does this PR do

  1. Make the logger work while loading the configuration file

    A few days ago, I noticed that the configuration file was no longer printed in verbose mode, and found that our logger will ONLY be initialized after loading the config file, this behavior was introduced in Allow setting misc.log_filters in config.toml #552, and this PR fixes it by setting our logger in 2 phases:

    1. Set up it with the log level (filter directives) specified in the CLI option

      let reload_handle = install_tracing(&opt.tracing_filter_directives())?;
    2. Update it with the log levels specified in the CLI option and the config file

      update_tracing(&reload_handle, &config.tracing_filter_directives())?;

      For more details, see the code comments

  2. Replace the default log level setting with a const variable DEFAULT_LOG_LEVEL

  3. Style change, import tracing::<log_macro!> when using it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If unknown config values are present, configuration is silently not loaded
1 participant