fix(library): honor the log level a node is configured with - #4056
fix(library): honor the log level a node is configured with#4056osmaczko wants to merge 1 commit into
Conversation
chronicles resolves each statement's level at compile time unless runtime filtering is enabled, and liblogosdelivery is built without it, so topics_registry.setLogLevel had nothing reading the level it stores. logging.setupLog, which Waku.new calls with the node configuration's logLevel, was therefore accepted and ignored: the library logged everything from the compile-time level up, and an embedding application had no way to quiet it. The runtime level starts at NONE, which admits every statement, so output is unchanged until an application sets one. The app targets already build with this define through their own nim.cfg.
|
The red jobs here are a dependency resolution problem, not this change. All five fail compiling
This change cannot reach those targets. The jobs that do build the library all pass: Scope of what that verifies: the define compiles on the nix and make paths. Nothing here exercises the behaviour, since no test asserts on log output. That a configured |
|
Closing: we can get what we need downstream without changing this repo.
Leaving the observation here in case it is useful to someone: the config key is plumbed all the way to Unrelated to this PR, but visible in its CI: several jobs failed compiling against |
Description
A node's
logLevelreaches chronicles:Waku.newpasses it tologging.setupLog, which callstopics_registry.setLogLevel. Nothing reads it back. chronicles consults the runtime level only when compiled withchronicles_runtime_filtering, which defaults to off, so each statement's level is resolved at compile time and the configured value is accepted and ignored.liblogosdelivery therefore logs everything from the compile-time level up and an application embedding it cannot quiet it. With
"logLevel": "ERROR"in the node configuration you still get a steady stream of DBG/INF lines: kademlia record walks every few seconds, filter subscription maintenance, autonat probes, mesh peer checks and heartbeats.Changes
library: enable chronicles runtime filtering
One define in
library/nim.cfg. It goes there rather than innix/default.nixso that every path that builds the library picks it up: the nix package flake consumers link, and themake liblogosdeliverytargets behind the release assets and the Windows DLL. It also matches howapps/*/nim.cfgalready configure chronicles,apps/wakucanary/nim.cfgwith this same define and nothing else.Behaviour does not change until an application sets a level. The runtime level is an
Atomic[LogLevel]that zero-initializes toNONEand the gate islogStmtLevel >= activeLogLevel, so with nothing configured every statement passes exactly as it does today. Topic-annotated statements take the same path, withTopicStatedefaulting toNormal. The compile-time level remains the ceiling, sochroniclesLogLevelstill decides what is available to select at runtime and existing overrides of it are unaffected.Not included, deliberately:
chronicles_sinksandchronicles_default_output_device, the pairlogging.setupLogFormatneeds beforelogFormatTEXT/JSON does anything. That is a separate defect, and enabling the dynamic device here would route every record logged beforesetupLogFormatruns throughdefaultDynamicWriter, which reports them on stderr as "log message not delivered" rather than printing them.Issue
No issue in this repo. Reported downstream as logos-co/logos-chat-ui#37, where an embedding application's console is dominated by this output.