* [pve-devel] [PATCH promxox-mail-forward] fix logging by switching to proxmox-log
@ 2025-06-12 12:34 Lukas Wagner
2025-06-12 15:16 ` Gabriel Goller
2025-06-13 7:56 ` [pve-devel] superseded: " Lukas Wagner
0 siblings, 2 replies; 4+ messages in thread
From: Lukas Wagner @ 2025-06-12 12:34 UTC (permalink / raw)
To: pve-devel
The proxmox-notify crate now uses tracing for logging, hence we have to
set up some tracing logging infrastructure if we want to see any
messages in the journal. Therefore we switch from the syslog crate to
proxmox-log, which configures the appropriate layers/subscribers for
tracing.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
Cargo.toml | 5 ++---
debian/control | 4 ++--
src/main.rs | 20 +++++++++++---------
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 8bbd89e..f23fc61 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.8"
proxmox-notify = {version = "0.5.4", features = ["mail-forwarder", "pve-context", "pbs-context"] }
+proxmox-sys = "0.6"
diff --git a/debian/control b/debian/control
index 48bd241..4ed6308 100644
--- a/debian/control
+++ b/debian/control
@@ -3,15 +3,15 @@ Section: rust
Priority: optional
Build-Depends: cargo:native,
debhelper-compat (= 13),
+ dh-cargo (>= 25),
librust-anyhow-1+default-dev,
- librust-log-0.4+default-dev (>= 0.4.17-~~),
librust-nix-0.26+default-dev,
+ librust-proxmox-log-0.2+default-dev (>= 0.2.8),
librust-proxmox-notify-0.5+default-dev (>= 0.5.4),
librust-proxmox-notify-0.5+mail-forwarder-dev,
librust-proxmox-notify-0.5+pbs-context-dev,
librust-proxmox-notify-0.5+pve-context-dev,
librust-proxmox-sys-0.6+default-dev,
- librust-syslog-6+default-dev,
libstd-rust-dev,
patchelf,
rustc:native,
diff --git a/src/main.rs b/src/main.rs
index 795b0f2..aaa8591 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -23,6 +23,9 @@ use std::path::Path;
use anyhow::Error;
+use proxmox_log::LevelFilter;
+use proxmox_log::Logger;
+use proxmox_log::error;
use proxmox_notify::Config;
use proxmox_notify::context::pbs::PBS_CONTEXT;
use proxmox_notify::context::pve::PVE_CONTEXT;
@@ -42,7 +45,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 +115,10 @@ 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) = Logger::from_env("PROXMOX_LOG", LevelFilter::INFO)
+ .journald()
+ .init()
+ {
eprintln!("unable to initialize syslog: {err}");
}
@@ -129,19 +131,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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pve-devel] [PATCH promxox-mail-forward] fix logging by switching to proxmox-log
2025-06-12 12:34 [pve-devel] [PATCH promxox-mail-forward] fix logging by switching to proxmox-log Lukas Wagner
@ 2025-06-12 15:16 ` Gabriel Goller
2025-06-13 7:46 ` Lukas Wagner
2025-06-13 7:56 ` [pve-devel] superseded: " Lukas Wagner
1 sibling, 1 reply; 4+ messages in thread
From: Gabriel Goller @ 2025-06-12 15:16 UTC (permalink / raw)
To: Lukas Wagner; +Cc: pve-devel
Printing anyhow errors with "{:#}" would be nice, so that the whole
context is visible as well.
Otherwise LGTM!
Consider:
Reviewed-by: Gabriel Goller <g.goller@proxmox.com>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pve-devel] [PATCH promxox-mail-forward] fix logging by switching to proxmox-log
2025-06-12 15:16 ` Gabriel Goller
@ 2025-06-13 7:46 ` Lukas Wagner
0 siblings, 0 replies; 4+ messages in thread
From: Lukas Wagner @ 2025-06-13 7:46 UTC (permalink / raw)
To: pve-devel, Gabriel Goller
On 2025-06-12 17:16, Gabriel Goller wrote:
> Printing anyhow errors with "{:#}" would be nice, so that the whole
> context is visible as well.
>
> Otherwise LGTM!
> Consider:
> Reviewed-by: Gabriel Goller <g.goller@proxmox.com>
Good point, I'll add the alternative formatter and add your R-b at the same time for a v2.
Thanks for the review!
--
- Lukas
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pve-devel] superseded: [PATCH promxox-mail-forward] fix logging by switching to proxmox-log
2025-06-12 12:34 [pve-devel] [PATCH promxox-mail-forward] fix logging by switching to proxmox-log Lukas Wagner
2025-06-12 15:16 ` Gabriel Goller
@ 2025-06-13 7:56 ` Lukas Wagner
1 sibling, 0 replies; 4+ messages in thread
From: Lukas Wagner @ 2025-06-13 7:56 UTC (permalink / raw)
To: pve-devel
Superseded-by: https://lore.proxmox.com/all/20250613075443.63136-1-l.wagner@proxmox.com/T/#u
On 2025-06-12 14:34, Lukas Wagner wrote:
> The proxmox-notify crate now uses tracing for logging, hence we have to
> set up some tracing logging infrastructure if we want to see any
> messages in the journal. Therefore we switch from the syslog crate to
> proxmox-log, which configures the appropriate layers/subscribers for
> tracing.
>
> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
> ---
> Cargo.toml | 5 ++---
> debian/control | 4 ++--
> src/main.rs | 20 +++++++++++---------
> 3 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/Cargo.toml b/Cargo.toml
> index 8bbd89e..f23fc61 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.8"
> proxmox-notify = {version = "0.5.4", features = ["mail-forwarder", "pve-context", "pbs-context"] }
> +proxmox-sys = "0.6"
> diff --git a/debian/control b/debian/control
> index 48bd241..4ed6308 100644
> --- a/debian/control
> +++ b/debian/control
> @@ -3,15 +3,15 @@ Section: rust
> Priority: optional
> Build-Depends: cargo:native,
> debhelper-compat (= 13),
> + dh-cargo (>= 25),
> librust-anyhow-1+default-dev,
> - librust-log-0.4+default-dev (>= 0.4.17-~~),
> librust-nix-0.26+default-dev,
> + librust-proxmox-log-0.2+default-dev (>= 0.2.8),
> librust-proxmox-notify-0.5+default-dev (>= 0.5.4),
> librust-proxmox-notify-0.5+mail-forwarder-dev,
> librust-proxmox-notify-0.5+pbs-context-dev,
> librust-proxmox-notify-0.5+pve-context-dev,
> librust-proxmox-sys-0.6+default-dev,
> - librust-syslog-6+default-dev,
> libstd-rust-dev,
> patchelf,
> rustc:native,
> diff --git a/src/main.rs b/src/main.rs
> index 795b0f2..aaa8591 100644
> --- a/src/main.rs
> +++ b/src/main.rs
> @@ -23,6 +23,9 @@ use std::path::Path;
>
> use anyhow::Error;
>
> +use proxmox_log::LevelFilter;
> +use proxmox_log::Logger;
> +use proxmox_log::error;
> use proxmox_notify::Config;
> use proxmox_notify::context::pbs::PBS_CONTEXT;
> use proxmox_notify::context::pve::PVE_CONTEXT;
> @@ -42,7 +45,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 +115,10 @@ 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) = Logger::from_env("PROXMOX_LOG", LevelFilter::INFO)
> + .journald()
> + .init()
> + {
> eprintln!("unable to initialize syslog: {err}");
> }
>
> @@ -129,19 +131,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}")
> }
> }
> }
--
- Lukas
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-13 7:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-12 12:34 [pve-devel] [PATCH promxox-mail-forward] fix logging by switching to proxmox-log Lukas Wagner
2025-06-12 15:16 ` Gabriel Goller
2025-06-13 7:46 ` Lukas Wagner
2025-06-13 7:56 ` [pve-devel] superseded: " Lukas Wagner
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