From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 3E01E1FF0AB for ; Wed, 23 Sep 2026 13:59:27 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C012C214DD; Wed, 23 Sep 2026 13:59:25 +0200 (CEST) From: Thomas Ellmenreich To: pdm-devel@lists.proxmox.com Subject: [RFC datacenter-manager/proxmox v2 0/4] log: allow finegrained control logging levels Date: Wed, 23 Sep 2026 13:57:58 +0200 Message-ID: <20260923115815.211083-1-t.ellmenreich@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1790164760379 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.531 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_SHORT 0.001 Use of a URL Shortener for very short URL RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: HIEM7SEUQ7SHMLWUL5UMORFLF7AVSIEU X-Message-ID-Hash: HIEM7SEUQ7SHMLWUL5UMORFLF7AVSIEU X-MailFrom: t.ellmenreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Thomas Ellmenreich X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 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 last three add tests as well as utilities to better communicate log levels to use cases that don't directly integrate with tracing. proxmox 1/4: 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/4: Actual implementation of EnvFilters. proxmox 3/4: 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'. datacenter-manager 4/4: Use proxmox_log::enabled! to check if DEBUG is enabled and use that to determine the REST server debug mode. 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. Open Questions -------------- - I had the idea that instead of having all users of the proxmox-log crate provide their own 'default_log_level' we could define that inside of the proxmox-log crate. By doing so, we could have the default change between DEBUG and INFO depending on if we are in a normal or release build. - Initially, I found case 3. of the different logging cases quite confusing and would have thought that our 'default_log_level' should apply as default in that case. Unfortunately, when setting 'default_log_level' and then applying the EnvFilter string, tracing applies the modules as expected, but then also overrides the default as '', which means off. Notes for the Maintainer ------------------------ For all tracing backed logging in Proxmox products to support EnvFilters, only patches 1 and 2 have to be applied. The 3 Patch only contains tests which I mostly used for understanding, but do still test our defaulting behaviour. Patch 4 is just something I noticed and fixed, but is not necessary to fix the Bugzilla issue: [2] Changelog --------- - 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 (3): log: replace per layer filtering by one global filter fix #6081: log: replace simple level filter with env filter log: add tests to the logger proxmox-log/Cargo.toml | 2 +- proxmox-log/src/builder.rs | 374 +++++++++++++++++++++++--- proxmox-log/src/lib.rs | 16 -- proxmox-log/src/pve_task_formatter.rs | 2 +- 4 files changed, 337 insertions(+), 57 deletions(-) proxmox-datacenter-manager: Thomas Ellmenreich (1): api: set REST server debug level based on actual log level server/src/bin/proxmox-datacenter-api/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Summary over all repositories: 5 files changed, 340 insertions(+), 59 deletions(-) -- Generated by murpp 0.12.0