From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id ED7331FF161 for ; Tue, 10 Sep 2024 15:10:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C113735F1C; Tue, 10 Sep 2024 15:10:31 +0200 (CEST) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Tue, 10 Sep 2024 15:09:57 +0200 Message-Id: <20240910130957.406624-1-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.045 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lib.rs] Subject: [pbs-devel] [PATCH] log: print error if env-var parsing failed, print correct name X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "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 --- 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::() { - log_level = l; + match v.parse::() { + 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::() { 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