Merge pull request #5892 from nuttycom/fix/hide_wallet_tool_logging_init_error

Default to error logging if we cannot parse the log filter
This commit is contained in:
Kris Nuttycombe 2022-04-21 16:06:35 -06:00 committed by GitHub
commit f8062d3995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -133,9 +133,16 @@ enum WalletToolError {
pub fn main() {
// Log to stderr, configured by the RUST_LOG environment variable.
let directive = env::var("RUST_LOG").unwrap_or_else(|_| "".to_string());
fmt()
.with_writer(io::stderr)
.with_env_filter(EnvFilter::from_default_env())
.with_env_filter(EnvFilter::try_new(&directive).unwrap_or_else(|_| {
eprintln!(
"Warning: could not parse filter directive '{}'\nfrom the RUST_LOG environment variable; using 'error' instead.\n",
&directive
);
EnvFilter::new("error")
}))
.init();
// Allow either Bitcoin-style or GNU-style arguments.