all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Thomas Ellmenreich" <t.ellmenreich@proxmox.com>
To: "Thomas Ellmenreich" <t.ellmenreich@proxmox.com>,
	<pdm-devel@lists.proxmox.com>
Subject: Re: [PATCH datacenter-manager 5/5] api: set REST server debug level based on actual log level
Date: Wed, 23 Sep 2026 09:48:01 +0200	[thread overview]
Message-ID: <DLMJ3MOBI7HN.5Q1J7KQSS7Z1@proxmox.com> (raw)
In-Reply-To: <20260921095210.229315-7-t.ellmenreich@proxmox.com>

On Mon Sep 21, 2026 at 11:51 AM CEST, Thomas Ellmenreich wrote:
> Use the configuration returned by the initialised logger to decide whether to
> activate debugging for the REST server.
>
> Previously, whether the REST server was in debug mode would only be determined
> by the existence of the PROXMOX_DEBUG variable, regardless of its value. Now,
> if the environment variable is set to a less verbose level than 'debug', the
> REST server will not activate its debug level.
>
> Signed-off-by: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
> ---
>  server/src/bin/proxmox-datacenter-api/main.rs | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/server/src/bin/proxmox-datacenter-api/main.rs b/server/src/bin/proxmox-datacenter-api/main.rs
> index 57aa6e22..7b2d85cb 100644
> --- a/server/src/bin/proxmox-datacenter-api/main.rs
> +++ b/server/src/bin/proxmox-datacenter-api/main.rs
> @@ -46,13 +46,15 @@ fn main() -> Result<(), Error> {
>  
>      server::env::sanitize_environment_vars();
>  
> -    let debug = std::env::var("PROXMOX_DEBUG").is_ok();
> -
> -    proxmox_log::Logger::from_env("PROXMOX_DEBUG", LevelFilter::INFO)
> +    let log_config = proxmox_log::Logger::from_env("PROXMOX_DEBUG", LevelFilter::INFO)
>          .journald_on_no_workertask()
>          .tasklog_pbs()
>          .init()?;
>  
> +    // NOTE: this will now also activate if a very specific module is set
> +    // to debug but the default level is still on info
> +    let debug = log_config.global_filter_max_level_hint() >= LevelFilter::DEBUG;

After working on another issue, I realised that the entire LoggerConfig part
could be removed and replaced with a simple 'proxmox_log::enabled!', which
would look like this:

```
let debug = proxmox_log::enabled!(LevelFilter::DEBUG);
```

This is cleaner and also removes the LoggerConfig, that is not really
needed outside of this single instance.

> +
>      if std::env::args().nth(1).is_some() {
>          bail!("unexpected command line parameters");
>      }





  reply	other threads:[~2026-09-23  7:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  9:51 [RFC datacenter-manager/proxmox 0/5] log: allow finegrained control logging levels Thomas Ellmenreich
2026-09-21  9:51 ` [PATCH proxmox 1/5] log: replace per layer filtering by one global filter Thomas Ellmenreich
2026-09-21  9:51 ` [PATCH proxmox 2/5] log: replace simple level filter with env filter Thomas Ellmenreich
2026-09-21  9:51 ` [PATCH proxmox 3/5] log: add tests to the logger Thomas Ellmenreich
2026-09-21  9:51 ` [PATCH proxmox 4/5] log: return the logger configuration after initialisation Thomas Ellmenreich
2026-09-21  9:51 ` [PATCH datacenter-manager 5/5] api: set REST server debug level based on actual log level Thomas Ellmenreich
2026-09-23  7:48   ` Thomas Ellmenreich [this message]
2026-09-23 12:00 ` superseded: [RFC datacenter-manager/proxmox 0/5] log: allow finegrained control logging levels Thomas Ellmenreich

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=DLMJ3MOBI7HN.5Q1J7KQSS7Z1@proxmox.com \
    --to=t.ellmenreich@proxmox.com \
    --cc=pdm-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