all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH datacenter-manager/proxmox v2 0/7] log: allow finegrained control log levels
@ 2026-10-23 11:31 Thomas Ellmenreich
  2026-10-23 11:31 ` [PATCH proxmox v2 1/7] log: replace per layer filtering with one global filter Thomas Ellmenreich
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Thomas Ellmenreich @ 2026-10-23 11:31 UTC (permalink / raw)
  To: pdm-devel; +Cc: Thomas Ellmenreich

The core of this change is a simple reinterpretation of the logging environment
variables that we are already using. Instead of parsing them as a single level
filter [0], they will now be interpreted as env filters [1]. Since the latter
can still parse all of the non erroring cases of the former, this change is
backwards compatible and will not break with any logging environment variables
that have been set.

Implementation
--------------

As Gabriel Goller proposed in this [2] Bugzilla enhancement, by using
EnvFilters [1], we can have more granular control over the logging happening in
the different Proxmox products. The first two commits do exactly this and can
thus be applied by themselves. The rest of the commits include cleanup, tests,
and some further improvements in rest server code that depended on the log
variable.

proxmox 1/7:
    A simple reordering of the logging layers. This had to be done since
    EnvFilter is currently not clonable and can thus be applied only once.
    Previously, the global filter was being applied unnecessarily often, on all
    layers and then on the tracing_log layer as well.

proxmox 2/7:
    Actual implementation of EnvFilters.

proxmox 3/7:
    Introduction of tests for our EnvFilter, parser, and constructor. This was
    initially created for me to better understand EnvFilters, but then evolved
    into tests to ensure consistent functionality with our 'default_log_level'.

proxmox 4/7:
    Simple clean up of empty structs to unit structs and unnecessarily
    explicit module paths that clutter struct definitions.

proxmox 5/7:
    Change the REST server default behaviour for setting its debug flag.
    Instead of defaulting to false, read the current log level and set it
    accordingly.

datacenter-manager 6/7:
    The REST server now reads the current log level to set its debug flag, so
    we can remove the code doing the same thing from the datacenter-manager side.

datacenter-manager 7/7:
    Replaced the PROXMOX_DEBUG environment variable by PDM_LOG, which is more
    in line with the other products. For both levels of api.

Different Log Options
---------------------

Combining the different options of the EnvFilter as well as our own default
log level, we have the following cases for logging:

1. Env contains 'simple':
    Meaning that the environment variable contains a simple 'info'... This
    means that that level is taken as the expected one.

2. Env contains 'simple', and 'module':
    Means that the env variable contains a simple log level as well as zero or
    more module specific log levels. As expected the simple level is applied
    as a default and then for the specified modules the defined levels apply.

3. Env only contains 'module':
    If the env only contains a module (or multiple), that is interpreted by
    tracing as disabling the default logging and only enabling logging for the
    module/s

4. Env is empty:
    No logs are printed at all, everything is hidden.

5. Env is not set:
    This is the only time the default comes into play, by being set as the
    default log level.

6. Env is gibberish:
    An error is printed to stderr and the default log level is used.

Notes for the Maintainer
------------------------

* To only apply the EnvFilter functionality the first two patches are the bare
  minimum, they restructure the filtering and then implement env filtering.

* Patches 3 and 4 add tests and some cleanup respectivly. Neither adds any
  functionality and they can be applied indipendently.

* Patches 5 and 6 should be applied together. No hard errors will appear if
  they are not applied together but Patch 6 epxects the REST server to set
  its own debug flag.

* Patch 7 could maybe be delayed to after the next release as it is a breaking
  change.

Future Work
-----------

Since the REST server now sets its own debug flag according to the log level,
other calls to the AcceptBuilder::debug() function can potentially be removed.
This is the case for proxmox_debug that currently does exactly what the REST
server will soon do by default.

Changelog
---------

- PATCH v1 -> v2 (thanks @Gabriel, @Lukas)
    * Also renamed the PROXMOX_DEBUG log variable into PDM_LOG for the
      privileged api, instead of only for the normal api.

    * I had previously removed the filter passed to the LogTracer, since
      LogTracer does not directly accept EnvFilter and the filter cannot
      be cloned. Now I get the max level in the EnvFilter and apply that as
      a LogTracer filter.

    * The REST server now checks the log level itself, so I removed the code
      setting the debug flag in proxmox-datacenter-manager.

    * Renamed the global_log_level to global_log_filter, as that is more
      fitting for a EnvFilter

- RFC v2 -> PATCH v1 (thanks @Lukas)
    * Split the 'proxmox 1/4' commit into two commits. Instead of mixing the
      global filter mix with the cleanup, they are now two different commits.
      To make sure that the core patches can be applied independently, the
      cleanup commit was moved to 'proxmox 3/6'.

    * Fixed some clippy warnings relating to documentation indenting.

    * Added tests that also directly call 'tracing' instead of just calling
      'log', just to confirm that both work and not just 'log'.

    * Introduced a new patch at the end, renaming the PROXMOX_DEBUG
      environment variable to PDM_LOG, as is default for all other products.

- RFC v1 -> v2
    * Removed patch 'v1 proxmox 4/5', which introduced a LoggerConfig returned
      by the Logger::init function. Deemed it unnecessary since I replaced the
      usage for it in patch 'v1 datacenter-manager 5/5' with a simple 'enabled!'
      and the idea of using it in the solution for [3] was abandoned.

    * Cleaned up this cover letter


[0]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.LevelFilter.html
[1]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html
[2]: https://bugzilla.proxmox.com/show_bug.cgi?id=6081
[3]: https://bugzilla.proxmox.com/show_bug.cgi?id=4646


proxmox:

Thomas Ellmenreich (5):
  log: replace per layer filtering with one global filter
  fix #6081: log: replace simple level filter with env filter
  log: add tests to the logger
  log: clean up of logger components
  rest-server: enable debug based on log level

 proxmox-log/Cargo.toml                |   2 +-
 proxmox-log/src/builder.rs            | 407 +++++++++++++++++++++++---
 proxmox-log/src/lib.rs                |  16 -
 proxmox-log/src/pve_task_formatter.rs |   2 +-
 proxmox-rest-server/src/connection.rs |   2 +-
 5 files changed, 370 insertions(+), 59 deletions(-)


proxmox-datacenter-manager:

Thomas Ellmenreich (2):
  api: remove manual setting of REST server debug flag
  api: rename PROXMOX_DEBUG log variable to PDM_LOG

 server/src/bin/proxmox-datacenter-api/main.rs     | 15 +++++++++------
 .../src/bin/proxmox-datacenter-privileged-api.rs  |  9 ++++++++-
 2 files changed, 17 insertions(+), 7 deletions(-)


Summary over all repositories:
  7 files changed, 387 insertions(+), 66 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-23 11:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23 11:31 [PATCH datacenter-manager/proxmox v2 0/7] log: allow finegrained control log levels Thomas Ellmenreich
2026-10-23 11:31 ` [PATCH proxmox v2 1/7] log: replace per layer filtering with one global filter Thomas Ellmenreich
2026-10-23 11:31 ` [PATCH proxmox v2 2/7] fix #6081: log: replace simple level filter with env filter Thomas Ellmenreich
2026-10-23 11:31 ` [PATCH proxmox v2 3/7] log: add tests to the logger Thomas Ellmenreich
2026-10-23 11:31 ` [PATCH proxmox v2 4/7] log: clean up of logger components Thomas Ellmenreich
2026-10-23 11:31 ` [PATCH proxmox v2 5/7] rest-server: enable debug based on log level Thomas Ellmenreich
2026-10-23 11:31 ` [PATCH datacenter-manager v2 6/7] api: remove manual setting of REST server debug flag Thomas Ellmenreich
2026-10-23 11:31 ` [PATCH datacenter-manager v2 7/7] api: rename PROXMOX_DEBUG log variable to PDM_LOG Thomas Ellmenreich

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