Skip to content

lightway-client log level can not directly change in command line #322

@yanganto

Description

@yanganto

Hi,
Before on-boarding, I try to play with lightway with my machines, and find out a possible issue on configure ordering. In case I forgot it, so I list down here and nothing urgent.

If there is any other consideration behind this, and this is not an issue, it will be nice to close it. If there is something I can do, I will be happy to go on this issue.

The previous configure order are

  1. option of cli
  2. environment variable
  3. config file

managed by following code.

let mut config = Config::with_layers(&[
Layer::Yaml(config_file.to_owned()),
Layer::Env(Some(String::from("LW_CLIENT_"))),
Layer::Clap(matches),
])?;


After the code increasing change in this month, the order will be a little be confused, because there are two environment variable do the same thing but different order. Besides, it is counter-intuitive, the cli option --log-level will be override by environment variable.

  1. environment variable(RUST_LOG)
  2. default directive (currently unset)
  3. option of cli
  4. environment variable(LW_CLIENT_LOG_LEVEL)
  5. config file (log_level field)

managed by following code.

let filter = tracing_subscriber::EnvFilter::builder()
// https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.Builder.html#method.with_regex
// recommends to disable REGEX when using envfilter from untrusted sources
.with_regex(false)
.from_env()
.unwrap_or_else(|_| {
// If RUST_LOG is not set, use config.log_level as default
let level: tracing::level_filters::LevelFilter = config.log_level.into();
tracing_subscriber::EnvFilter::new(level.to_string())
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions