feat(node): update log level via admin API - #25281
Open
spalladino wants to merge 1 commit into
Open
Conversation
Adds a logLevel key to the node admin config, settable at runtime via aztecAdmin_setConfig using the LOG_LEVEL env var format (e.g. "debug;trace:sequencer,p2p") and reported by aztecAdmin_getConfig. Since pino child loggers do not follow their parent's level after creation, foundation now keeps a weak registry of all live child loggers (including libp2p ones) and exposes setLogLevel/getLogLevel to update their levels in place. New loggers created after the change pick up the updated levels as well. Only affects the node process; spawned processes keep their own configuration, and a restart reverts to the LOG_LEVEL env var.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow changing the log level of a running node at runtime through the node admin API, instead of only via the
LOG_LEVELenv var at startup.Context
Diagnosing issues on a live node often requires more verbose logging, but until now the only way to change the log level was restarting the node with a different
LOG_LEVEL— losing the state you were trying to observe.Approach
logLevelkey toAztecNodeAdminConfig, so it flows through the existingaztecAdmin_setConfig/aztecAdmin_getConfigmethods with their auth and merge semantics. The value uses the same spec format as theLOG_LEVELenv var (e.g.debug;trace:sequencer,p2p) and is validated at the RPC boundary.@aztec/foundation/lognow keeps a registry of all live child loggers (weakly held viaWeakRef/FinalizationRegistry, since some paths create short-lived per-tx loggers). A newsetLogLevelre-levels the root and every registered child per the new filters; loggers created afterwards pick up the new levels too. libp2p component loggers go through the same registry.trace, so gating happens entirely at the logger.The change only affects the node's own process — spawned prover agents and external binaries keep their configuration — and is not persisted: a restart reverts to the
LOG_LEVELenv var.API changes
AztecNodeAdmin.setConfigaccepts an optionallogLevelstring andgetConfigreports the current spec.@aztec/foundation/logexports newsetLogLevel,getLogLevel,formatLogLevelSpec, andisValidLogLevelSpecfunctions.Example: