[pbs-devel] [PATCH] log: print error if env-var parsing failed, print correct name
Gabriel Goller
g.goller at proxmox.com
Tue Sep 10 15:09:57 CEST 2024
Print error if the parsing of the env-var fails on the proxmox-backup-*
daemons as well. Output correct env-var on binaries that use different
variables.
Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
---
proxmox-log/src/lib.rs | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/proxmox-log/src/lib.rs b/proxmox-log/src/lib.rs
index 27d0b8a23e91..332f66221477 100644
--- a/proxmox-log/src/lib.rs
+++ b/proxmox-log/src/lib.rs
@@ -44,8 +44,13 @@ pub fn init_logger(
) -> Result<(), anyhow::Error> {
let mut log_level = default_log_level;
if let Ok(v) = env::var(env_var_name) {
- if let Ok(l) = v.parse::<LevelFilter>() {
- log_level = l;
+ match v.parse::<LevelFilter>() {
+ Ok(l) => {
+ log_level = l;
+ }
+ Err(e) => {
+ eprintln!("env variable {env_var_name} found, but parsing failed: {e:?}");
+ }
}
}
let registry = tracing_subscriber::registry()
@@ -165,9 +170,9 @@ pub fn init_cli_logger(
match v.parse::<LevelFilter>() {
Ok(l) => {
log_level = l;
- },
+ }
Err(e) => {
- eprintln!("env variable PBS_LOG found, but parsing failed: {e:?}");
+ eprintln!("env variable {env_var_name} found, but parsing failed: {e:?}");
}
}
}
--
2.39.2
More information about the pbs-devel
mailing list