feat(observability): centralized admin-tunable event log levels - #106
Merged
Merged
Conversation
Adds observability::log(env, level, topics, data) as the single choke point every events.rs helper now routes through, plus a LogLevel enum (Debug/Info/Warn/Error) with a per-network compiled default (Debug on dev, Info on testnet via the `testnet` feature, Warn on mainnet via the `mainnet` feature). The effective threshold is durably overridable at runtime through the admin-only set_log_level entry point, so a live mainnet contract can quiet or raise verbosity without a redeploy. The ad-hoc #[cfg(feature = "logging")] blocks in lib.rs (swap, safe_swap) are replaced with unconditional calls through the same log() gate, since compile-time-only flags gave mainnet no runtime control. Existing event names and payloads are unchanged - only whether they publish depends on the configured level. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
Great job consolidating event log levels behind a single admin-tunable knob — much friendlier to operators. CI is green. Clean implementation, merging 🚀 |
Contributor
|
The centralized log-level knob is a clean follow-up — thanks for the work 👋 Heads up: while processing the queue, I merged PRs #101, #102, #103, #104-attempt, #105-attempt, and #110 ahead of yours. This branch edited Could you rebase onto the latest |
This was referenced Jul 19, 2026
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.
Closes #95
Summary
Introduces a centralized logging abstraction so mainnet builds get runtime
log-level control instead of the old compile-time-only
#[cfg(feature = "logging")]flag.src/observability.rs:LogLevel { Debug, Info, Warn, Error }enumand
log(env, level, topics, data)— the single choke point everystructured event now routes through.
Debugon dev,Infoontestnetfeature,
Warnonmainnetfeature), overridable at runtime.set_log_level(env, caller, level)— admin-only (require_auth+require_admin), durably persisted so it survives calls/upgrades.get_log_level(env)added as a companion view.events.rsrewritten to calllog()with an assignedseverity. Event names and payloads are unchanged (additive only).
#[cfg(feature = "logging")]blocks inlib.rs(
swap,safe_swap) now go through the same runtime-gatedlog()call instead of a compile-time-only flag.
the admin override flow, and guidance for adding new events.
Test plan
observability_tests.rscovers:set_log_levelrejects non-admin callersDebugthreshold lets all 4 severities throughWarnthreshold allows onlyWarn/Error(event-count assertion)Errorthreshold silences everything exceptError-level events(event-count assertion, per acceptance criteria)
cargo test --workspace --lib