[pdm-devel] applied: [PATCH proxmox-datacenter-manager v2] api: priv-api: admin-cli: use new logger builder

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Apr 14 16:46:07 CEST 2025


applied, thanks

On Fri, Apr 11, 2025 at 02:10:28PM +0200, Lukas Wagner wrote:
> The Logger::tasklog_pbs is actually not specific to PBS but should be
> used for anything that uses WorkerTasks with a LogContext.
> 
> Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
> Reviewed-by: Gabriel Goller <g.goller at proxmox.com>
> ---
> 
> Notes:
>     We might want to rename Logger::tasklog_pbs at some point.
> 
>  cli/admin/src/main.rs                               | 5 ++++-
>  server/src/bin/proxmox-datacenter-api/main.rs       | 6 +++++-
>  server/src/bin/proxmox-datacenter-privileged-api.rs | 5 ++++-
>  3 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/cli/admin/src/main.rs b/cli/admin/src/main.rs
> index 5fa9116b..91b93f3c 100644
> --- a/cli/admin/src/main.rs
> +++ b/cli/admin/src/main.rs
> @@ -4,7 +4,10 @@ mod remotes;
>  
>  fn main() {
>      //pbs_tools::setup_libc_malloc_opts(); // TODO: move from PBS to proxmox-sys and uncomment
> -    proxmox_log::init_cli_logger("PDM_LOG", proxmox_log::LevelFilter::INFO)
> +
> +    proxmox_log::Logger::from_env("PDM_LOG", proxmox_log::LevelFilter::INFO)
> +        .stderr()
> +        .init()
>          .expect("failed to set up logger");
>  
>      server::context::init().expect("could not set up server context");
> diff --git a/server/src/bin/proxmox-datacenter-api/main.rs b/server/src/bin/proxmox-datacenter-api/main.rs
> index 25852c8c..771fe45f 100644
> --- a/server/src/bin/proxmox-datacenter-api/main.rs
> +++ b/server/src/bin/proxmox-datacenter-api/main.rs
> @@ -46,7 +46,11 @@ fn main() -> Result<(), Error> {
>      server::env::sanitize_environment_vars();
>  
>      let debug = std::env::var("PROXMOX_DEBUG").is_ok();
> -    proxmox_log::init_logger("PROXMOX_DEBUG", LevelFilter::INFO)?;
> +
> +    proxmox_log::Logger::from_env("PROXMOX_DEBUG", LevelFilter::INFO)
> +        .journald_on_no_workertask()
> +        .tasklog_pbs()
> +        .init()?;
>  
>      if std::env::args().nth(1).is_some() {
>          bail!("unexpected command line parameters");
> diff --git a/server/src/bin/proxmox-datacenter-privileged-api.rs b/server/src/bin/proxmox-datacenter-privileged-api.rs
> index 0e23a5f1..1f8a947c 100644
> --- a/server/src/bin/proxmox-datacenter-privileged-api.rs
> +++ b/server/src/bin/proxmox-datacenter-privileged-api.rs
> @@ -23,7 +23,10 @@ fn main() -> Result<(), Error> {
>  
>      server::env::sanitize_environment_vars();
>  
> -    proxmox_log::init_logger("PROXMOX_DEBUG", LevelFilter::INFO)?;
> +    proxmox_log::Logger::from_env("PROXMOX_DEBUG", LevelFilter::INFO)
> +        .journald_on_no_workertask()
> +        .tasklog_pbs()
> +        .init()?;
>  
>      create_directories()?;
>  
> -- 
> 2.39.5




More information about the pdm-devel mailing list