-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
kernel, logging: Pass Logger instances to kernel objects #30342
base: master
Are you sure you want to change the base?
Conversation
Improve new LogDebug(), LogTrace(), LogInfo(), LogWarning(), LogError() macros introduced in bitcoin#28318: - Make them always accept log categories to make it possible to only log messages from a particular component. - Make them not rely on a global LogInstance, to provide better control of logging in controlled environments, such as unit tests that want to selectively capture log output, or libbitcoinkernel applications that want to have multiple instances of validation objects without mixing their log output. - Make them consistent, now all accepting the same parameters. - Make them less verbose by not requiring BCLog category constants to be specified in individual log prints
Needed to fix errors like: const Source &_LogSource(const Source &)': expects 1 arguments - 3 provided const Source &_LogSource(const Source &)': expects 1 arguments - 3 provided due to a compiler bug: https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly/5134656#5134656 Example CI failure: https://github.com/bitcoin/bitcoin/actions/runs/8072891468/job/22055528830?pr=29256
Pass Logger instances to BlockManager, CCoinsViewDB, CDBWrapper, ChainstateManager, and CoinsViews instances so libbitcoinkernel applications and test code have the option to control where log output goes instead of having all output sent to the global logger. This commit just passes the logger objects without using them. The next commit updates log print statements to use the new objects.
This is a mechanical change updating kernel code that currently uses the global log instance to log to local instances instead.
This allows libbitcoinkernel applications and test code to have the option to control where log output goes instead of having all output sent to the global logger.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Concept ACK. |
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
Updated 4542335 -> db1b9f7 ( |
Pass
Logger
instances toBlockManager
,CCoinsViewDB
,CDBWrapper
,Chainstate
,ChainstateManager
,CoinsViews
, andCTxMemPool
classes so libbitcoinkernel applications and tests have the option to control where log output goes instead of having all output sent to the global logger.This PR is an alternative to #30338. It is more limited because it only changes kernel code while leaving other parts of the codebase alone. It also takes the opportunity to migrate legacy LogPrint / LogPrintf calls to the new log macros introduced in #28318.
This is based on #29256. The non-base commits are:
e9b91f5c5c92
refactor: Pass Logger instances to kernel objectsfacc2d0edff9
refactor: Log kernel output to local log instancesdb1b9f7696af
refactor: Pass Logger instance to CTxMemPool