From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 972B41FF164 for ; Fri, 6 Dec 2024 11:10:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1305B1C6C; Fri, 6 Dec 2024 11:10:20 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Date: Fri, 6 Dec 2024 11:10:07 +0100 Message-Id: <20241206101007.156910-2-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241206101007.156910-1-l.wagner@proxmox.com> References: <20241206101007.156910-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.009 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH proxmox-mail-forward 2/2] switch to proxmox-log X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" The proxmox-notify crate now uses tracing for logging, hence we have to switch to proxmox-log (which configures the appropriate layers/subscribers for tracing). Signed-off-by: Lukas Wagner --- Cargo.toml | 5 ++--- src/main.rs | 16 +++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0f4e3b0..9dc081b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,8 @@ exclude = [ "debian" ] [dependencies] anyhow = "1.0" -log = "0.4.17" nix = "0.26" -syslog = "6.0" -proxmox-sys = "0.6" +proxmox-log = "0.2" proxmox-notify = {version = "0.5", features = ["mail-forwarder", "pve-context", "pbs-context"] } +proxmox-sys = "0.6" diff --git a/src/main.rs b/src/main.rs index 4662ffa..c0ea561 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,8 @@ use std::path::Path; use anyhow::Error; +use proxmox_log::error; +use proxmox_log::LevelFilter; use proxmox_notify::context::pbs::PBS_CONTEXT; use proxmox_notify::context::pve::PVE_CONTEXT; use proxmox_notify::Config; @@ -42,7 +44,7 @@ fn attempt_file_read>(path: P) -> Option { match fs::file_read_optional_string(path.as_ref()) { Ok(contents) => contents, Err(err) => { - log::error!("unable to read {path:?}: {err}", path = path.as_ref()); + error!("unable to read {path:?}: {err}", path = path.as_ref()); None } } @@ -112,11 +114,7 @@ fn forward_for_pbs(mail: &[u8], has_pve: bool) -> Result<(), Error> { } fn main() { - if let Err(err) = syslog::init( - syslog::Facility::LOG_DAEMON, - log::LevelFilter::Info, - Some("proxmox-mail-forward"), - ) { + if let Err(err) = proxmox_log::init_logger("PROXMOX_LOG", LevelFilter::INFO) { eprintln!("unable to initialize syslog: {err}"); } @@ -129,19 +127,19 @@ fn main() { if Path::new(PVE_CFG_PATH).exists() { has_pve = true; if let Err(err) = forward_for_pve(&mail) { - log::error!("could not forward mail for Proxmox VE: {err}"); + error!("could not forward mail for Proxmox VE: {err}"); } } // Assume a PBS installation if /etc/proxmox-backup exists if Path::new(PBS_CFG_PATH).exists() { if let Err(err) = forward_for_pbs(&mail, has_pve) { - log::error!("could not forward mail for Proxmox Backup Server: {err}"); + error!("could not forward mail for Proxmox Backup Server: {err}"); } } } Err(err) => { - log::error!("could not read mail from STDIN: {err}") + error!("could not read mail from STDIN: {err}") } } } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel