From: Gabriel Goller <g.goller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH] log: print error if env-var parsing failed, print correct name
Date: Tue, 10 Sep 2024 15:09:57 +0200 [thread overview]
Message-ID: <20240910130957.406624-1-g.goller@proxmox.com> (raw)
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@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
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next reply other threads:[~2024-09-10 13:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 13:09 Gabriel Goller [this message]
2024-09-16 13:13 ` [pbs-devel] applied: " Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240910130957.406624-1-g.goller@proxmox.com \
--to=g.goller@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.