public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH] log: print error if env-var parsing failed, print correct name
@ 2024-09-10 13:09 Gabriel Goller
  2024-09-16 13:13 ` [pbs-devel] applied: " Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Gabriel Goller @ 2024-09-10 13:09 UTC (permalink / raw)
  To: pbs-devel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH] log: print error if env-var parsing failed, print correct name
  2024-09-10 13:09 [pbs-devel] [PATCH] log: print error if env-var parsing failed, print correct name Gabriel Goller
@ 2024-09-16 13:13 ` Wolfgang Bumiller
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2024-09-16 13:13 UTC (permalink / raw)
  To: Gabriel Goller; +Cc: pbs-devel

applied, thanks


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-16 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-10 13:09 [pbs-devel] [PATCH] log: print error if env-var parsing failed, print correct name Gabriel Goller
2024-09-16 13:13 ` [pbs-devel] applied: " Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal