Skip to content

use tracing crate instead of log - #1020

Merged
spacebear21 merged 2 commits into
payjoin:masterfrom
nothingmuch:tracing-instead-of-log-crate
Aug 29, 2025
Merged

spacebear21 merged 2 commits into
payjoin:masterfrom
nothingmuch:tracing-instead-of-log-crate

Conversation

@nothingmuch

Copy link
Copy Markdown
Contributor

This makes logs events from the payjoin and payjoin-cli crates log using the tracing crate, like most of our dependencies and the payjoin-directory crate.

The main rationale is that the log crate is effectively part of our public API, which necessitates the use of the tracing-log crate to integrate with the tracing crate, which is more commonly used.

The main visible effect of this is that payjoin crate output is now visible by default when running tests, previously on the tracing logs were initialized in payjoin-test-utils, without using the tracing-log crate (see #584), and without using env_logger.

Related #509, #821

Supersedes #584

Pull Request Checklist

Please confirm the following before requesting review:

@nothingmuch
nothingmuch force-pushed the tracing-instead-of-log-crate branch from a51fc34 to ef92391 Compare August 29, 2025 17:46
@coveralls

coveralls commented Aug 29, 2025 •

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 17331627962

Details

  • 32 of 42 (76.19%) changed or added relevant lines in 15 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 85.916%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/v2/ohttp.rs 0 1 0.0%
payjoin/src/core/receive/mod.rs 6 7 85.71%
payjoin-cli/src/app/v2/mod.rs 0 2 0.0%
payjoin-cli/src/app/v1.rs 4 10 40.0%
Totals Coverage Status
Change from base Build 17330726476: 0.003%
Covered Lines: 8168
Relevant Lines: 9507

💛 - Coveralls

@nothingmuch
nothingmuch force-pushed the tracing-instead-of-log-crate branch from ef92391 to bbbd35a Compare August 29, 2025 17:49

@DanGould DanGould left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

test_local passes. Though I'm not sure I'm seeing the default logging you bring up in the body.

ACK bbbd35a

@nothingmuch

Copy link
Copy Markdown
Contributor Author

to view the logs when tests pass you need to run something like cargo test -p payjoin --test integration -- --nocapture, otherwise they are only printed on failure, and additionally the log level filter has to allow outputs (the payjoin crate only uses debug & trace events on the happy path). also note that if RUST_LOG=debug or trace, bitcoind's log output is also printed to stdout (perhaps that should be enabled only on trace to suppress noise?), this output is not related.

@nothingmuch

Copy link
Copy Markdown
Contributor Author

BTW, the log feature is not enabled by default, but if it is enabled then this would essentially allow tracing without fully opting out of the log crate https://docs.rs/tracing/latest/tracing/#emitting-log-records

This allows specifying RUST_LOG=trace,bitcoind=info to suppress bitcoind
output, or RUST_LOG=bitcoind=trace to only show bitcoind output.

The default level to enable it is also TRACE instead of DEBUG as of this
commit.
@nothingmuch
nothingmuch force-pushed the tracing-instead-of-log-crate branch from a530f9a to a0f6511 Compare August 29, 2025 18:36

@spacebear21 spacebear21 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.

tACK a0f6511 and confirmed bitcoind logs are printed when RUST_LOG=trace

@nothingmuch

Copy link
Copy Markdown
Contributor Author

hmm, @DanGould you didn't say if you were convinced by my arguments for why this should get merged before 1.0, were you persuaded?

@DanGould

Copy link
Copy Markdown
Member

Little's law. I wouldn't have added it to the queue, but leaving things on the queue otherwise slows us down.

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.

4 participants