Skip to content

Respect the log facade's level filters in LogFacadeWriter - #1167

Merged
tnull merged 2 commits into
lightningdevkit:mainfrom
cryptokvc:log-facade-level-filter
Oct 15, 2026
Merged

tnull merged 2 commits into
lightningdevkit:mainfrom
cryptokvc:log-facade-level-filter

Conversation

@cryptokvc

@cryptokvc cryptokvc commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1139.

Writer::LogFacadeWriter built a log::Record and passed it to log::logger().log(). That skips the checks the log macros perform first, level <= STATIC_MAX_LEVEL && level <= log::max_level(). An application that calls log::set_max_level(LevelFilter::Error) still got Info, Debug and Trace records from LDK Node.

The writer now maps the level first and returns early when it fails either check, under both uniffi configurations. The level mapping, target, module path, line and structured context are unchanged. It doesn't consult Log::enabled(), matching what the macros do.

cargo test --lib logger:: passes, with and without --features uniffi.

AI disclosure: written with the help of an AI assistant (Claude), then reviewed and tested by me.

LogFacadeWriter passed records straight to `log::logger().log()`, so
records above the facade's `max_level()` or `STATIC_MAX_LEVEL` still
reached the application's logger. Apply the same checks as the `log`
macros before building the record.

The unit tests that use the global facade logger now share one logger
and a lock, since the logger can only be set once per process.

Written with the help of an AI assistant (Claude); reviewed and tested
by me.
@ldk-reviews-bot

ldk-reviews-bot commented Oct 14, 2026 •

Copy link
Copy Markdown

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot
ldk-reviews-bot requested a review from tnull October 14, 2026 13:10

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Production changes look good, but let's just drop the test changes. I'm not sure it's worth testing this to begin with, but the lock also risks having concurrent tests block on each other.

As requested in review, keep only the LogFacadeWriter change.
@cryptokvc

Copy link
Copy Markdown
Contributor Author

Dropped the test changes, so the PR now only touches the writer.

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tnull
tnull merged commit 4d4d059 into lightningdevkit:main Oct 15, 2026
16 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect configured log facade level filters

3 participants