Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix log-facade logging and clarify max level #454

Merged
merged 4 commits into from
Feb 4, 2025

Conversation

tnull
Copy link
Collaborator

@tnull tnull commented Jan 31, 2025

This is another small follow-up to #407.

Previously, the log facade logger would always use a logger target but then also add the correct module paht and line as part of the normal log messages. Here, we override the log target correctly.

Moreover, we previously would log all messages at the configured maximum level, not the level in the log record. We therefore also fix this and rename level to max_log_level everywhere to clear up any confusions regarding what the variable does.

(cc @enigbe)

@tnull tnull requested a review from joostjager January 31, 2025 12:07
src/builder.rs Outdated Show resolved Hide resolved
src/builder.rs Outdated Show resolved Hide resolved
src/logger.rs Show resolved Hide resolved
bindings/ldk_node.udl Outdated Show resolved Hide resolved
@tnull tnull force-pushed the 2025-01-fix-env-logger branch from 869bfc7 to 90dba9e Compare February 1, 2025 09:24
Copy link
Contributor

@enigbe enigbe left a comment

Choose a reason for hiding this comment

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

Thanks for catching this @tnull.

Part of the conversation we had when reviewing #407 was to add a follow-up that addressed testing the writers in ways that didn't clutter the existing tests. I will be adding those tests shortly but I have tested this with a log facade writer locally and it logs entries correctly.

@tnull tnull requested a review from joostjager February 3, 2025 14:36
tnull added 4 commits February 4, 2025 16:09
Previously, the log facade logger would always use a `logger` target but
then *also* add the correct module path and line as part of the normal
log messages. Here, we override the log target correctly.

Moreover, we previously would log all messages at the configured
*maximum* level, not the level in the log record.
@tnull tnull force-pushed the 2025-01-fix-env-logger branch from 90dba9e to 9f2714c Compare February 4, 2025 15:09
@tnull
Copy link
Collaborator Author

tnull commented Feb 4, 2025

Rebased on main to fix CI.

Copy link
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

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

Tested and looks identical to the file logger output now.

Some(LogWriterConfig::Log(log_level)) => Logger::new_log_facade(*log_level),
Some(LogWriterConfig::Log { max_log_level }) => {
let max_log_level = max_log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL);
Logger::new_log_facade(max_log_level)
Copy link
Contributor

@joostjager joostjager Feb 4, 2025

Choose a reason for hiding this comment

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

One thing that I noticed about the log facade is that you can set log level GOSSIP, but that isn't visible anymore after this PR. The standard log only knows TRACE of course. Not a problem I think?

And perhaps some explanation on how the RUST_LOG env var interacts with this log level would be helpful too. It wasn't very clear to me how that works. Maybe there is a way to set RUST_LOG programmatically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

One thing that I noticed about the log facade is that you can set log level GOSSIP, but that isn't visible anymore after this PR. The standard log only knows TRACE of course. Not a problem I think?

Yeah, I think it's not super important. We could consider adding something special in the target or message itself, but I'd wait for a user to complain about it. So far, I assume it's fine to squash TRACE and GOSSIP together in this case.

And perhaps some explanation on how the RUST_LOG env var interacts with this log level would be helpful too. It wasn't very clear to me how that works. Maybe there is a way to set RUST_LOG programmatically?

Ah, RUST_LOG is entirely out-of-scope here, as it's a special behavior of env_logger, which is just one of the backends for the log facade. env_logger users simply need to read their docs and discover that it's mandatory to set RUST_LOG (see https://docs.rs/env_logger/latest/env_logger/#enabling-logging).

@tnull tnull merged commit 8bfa8ec into lightningdevkit:main Feb 4, 2025
10 of 14 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.

3 participants