all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-mail-forward 2/2] switch to proxmox-log
Date: Fri,  6 Dec 2024 11:10:07 +0100	[thread overview]
Message-ID: <20241206101007.156910-2-l.wagner@proxmox.com> (raw)
In-Reply-To: <20241206101007.156910-1-l.wagner@proxmox.com>

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 <l.wagner@proxmox.com>
---
 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<P: AsRef<Path>>(path: P) -> Option<String> {
     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


  reply	other threads:[~2024-12-06 10:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06 10:10 [pve-devel] [PATCH proxmox 1/2] notify: smtp: add missing 'tracing' namespace prefix Lukas Wagner
2024-12-06 10:10 ` Lukas Wagner [this message]
2024-12-06 10:40   ` [pve-devel] [PATCH proxmox-mail-forward 2/2] switch to proxmox-log Gabriel Goller
2024-12-06 12:07     ` Lukas Wagner
2025-03-18 10:48   ` Fabian Grünbichler
2025-03-19  9:39     ` Gabriel Goller
2024-12-06 10:20 ` [pve-devel] [PATCH proxmox 1/2] notify: smtp: add missing 'tracing' namespace prefix Gabriel Goller
2025-03-18 10:48 ` Fabian Grünbichler

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=20241206101007.156910-2-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pve-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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal