-
Notifications
You must be signed in to change notification settings - Fork 15
Description
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
- option of cli
- environment variable
- config file
managed by following code.
lightway/lightway-client/src/main.rs
Lines 75 to 79 in 08d8038
| 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.
- environment variable(RUST_LOG)
- default directive (currently unset)
- option of cli
- environment variable(LW_CLIENT_LOG_LEVEL)
- config file (log_level field)
managed by following code.
lightway/lightway-client/src/main.rs
Lines 81 to 90 in 08d8038
| 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()) | |
| }); |