Skip to content

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Apr 3, 2024

  • Move special cases from LOG_CATEGORIES_BY_STR to GetLogCategory() (suggested here).

  • Remove "none" and "0" from RPC logging help because that help text was wrong. "none" resulted in an error and "0" was ignored itself (contrary to what the help text suggested).

  • Remove unused LOG_CATEGORIES_BY_STR[""] (suggested here).

This is a followup to #29419, addressing leftover suggestions + more.

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 3, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK LarryRuane, ryanofsky
Concept ACK kevkevinpal
Stale ACK ajtowns

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29415 (Broadcast own transactions only via short-lived Tor or I2P connections by vasild)
  • #26697 (logging: use bitset for categories by LarryRuane)
  • #17783 (util: Fix -norpcwhitelist, -norpcallowip, and similar corner case behavior by ryanofsky)
  • #17581 (refactor: Remove settings merge reverse precedence code by ryanofsky)
  • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky)
  • #17493 (util: Forbid ambiguous multiple assignments in config file by ryanofsky)

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.

@jonatack
Copy link
Member

jonatack commented Apr 3, 2024

See #27231.

@vasild
Copy link
Contributor Author

vasild commented Apr 3, 2024

See #27231.

There you mention:

I'm going to open an alternate pull that does what you suggest...

Is the current PR doing what you meant? E.g. drop that help text and return an error for "0" ("none" already returns an error in master)?

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK d98ca05

Nice cleanups! Main feedback I have is to more clearly indicate which commits are refactoring, and which have behavior changes. Would suggest putting "logging, refactor:" in refactoring commit titles and "logging:" in commits that change behavior. Also I would consider dropping any behavior changes that aren't obvious improvments and doing them in separate PRs so they have more visibility and are not lost in "logging cleanup."

Copy link
Contributor

@kevkevinpal kevkevinpal left a comment

Choose a reason for hiding this comment

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

Concept ACK

just a question is there any reason to keep BCLog::NONE in logging.h and not completely delete it I did
grep --exclude-dir=".deps" -nri "BCLog::NONE" ./src/ --binary-files=without-match
and
grep --exclude-dir=".deps" -nri "LogFlags::NONE" ./src/ --binary-files=without-match
and only see it being used in ./src/logging.{h,cpp} and ./src//qt/transactiondesc.cpp

@vasild vasild force-pushed the logging_cleanup branch from d98ca05 to bee2240 Compare May 5, 2024 17:29
@vasild
Copy link
Contributor Author

vasild commented May 5, 2024

d98ca056a8...bee22409ea: rebase and address suggestions

Edit: @kevkevinpal, I am not sure about dropping BCLog::NONE on the technical side, but what is sure is that it would further increase the scope of this PR, so I am leaving it as it is :)

@DrahtBot
Copy link
Contributor

DrahtBot commented May 5, 2024

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/24605970251

@vasild
Copy link
Contributor Author

vasild commented May 5, 2024

bee22409ea...df2422c5f9: fix CI

this compiles locally but not on the CI:

ret.emplace_back(category, WillLogCategory(flag));

so instead use:

ret.push_back(LogCategory{.category = category, .active = WillLogCategory(flag)});

@DrahtBot DrahtBot removed the CI failed label May 5, 2024
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK df2422c. Looks good, this gets rid of some unnecessary complexity and strange behavior in logging RPC.

@ajtowns
Copy link
Contributor

ajtowns commented Jul 3, 2024

Consider also updating the help text for -debug and -debugexclude:

--- a/src/init/common.cpp
+++ b/src/init/common.cpp
@@ -27,9 +27,9 @@ void AddLoggingArgs(ArgsManager& argsman)
 {
     argsman.AddArg("-debuglogfile=<file>", strprintf("Specify location of debug log file (default: %s). Relative paths will be prefixed by a net-specific datadir location. Pass -nodebuglogfile to disable writing the log to a file.", DEFAULT_DEBUGLOGFILE), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
     argsman.AddArg("-debug=<category>", "Output debug and trace logging (default: -nodebug, supplying <category> is optional). "
-        "If <category> is not supplied or if <category> = 1, output all debug and trace logging. <category> can be: " + LogInstance().LogCategoriesString() + ". This option can be specified multiple times to output multiple categories.",
+        "If <category> is not supplied or if <category> is 1 or \"all\", output all debug logging. If <category> is 0 or \"none\", any other categories are ignored. Other valid values for <category> are: " + LogInstance().LogCategoriesString() + ". This option can be specified multiple times to output multiple categories.",
         ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
-    argsman.AddArg("-debugexclude=<category>", "Exclude debug and trace logging for a category. Can be used in conjunction with -debug=1 to output debug and trace logging for all categories except the specified category. This option can be specified multiple times to exclude multiple categories.", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
+    argsman.AddArg("-debugexclude=<category>", "Exclude debug and trace logging for a category. Can be used in conjunction with -debug=1 to output debug and trace logging for all categories except the specified category. This option can be specified multiple times to exclude multiple categories. This takes priority over \"-debug\"", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);

@ajtowns
Copy link
Contributor

ajtowns commented Jul 3, 2024

ACK df2422c ; looks like it behaves correctly to me

Copy link
Contributor

@LarryRuane LarryRuane left a comment

Choose a reason for hiding this comment

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

ACK (but needs rebase, will re-ACK), this will make #26697 simpler (so I think the current PR should merge first). Comments are minor, feel free to ignore.

@vasild
Copy link
Contributor Author

vasild commented Aug 2, 2024

df2422c5f9...397211b573: rebase due to conflicts

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 397211b, just since rebase since last review.

@vasild AJ's documentation suggestion also seems like it would be an improvement
#29798 (comment) (though I didn't look into the details and verify it is accurate).

@DrahtBot DrahtBot requested review from LarryRuane and ajtowns August 2, 2024 17:15
Copy link
Contributor

@LarryRuane LarryRuane left a comment

Choose a reason for hiding this comment

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

ACK 397211b
I will re-ACK if you make that one small suggested change.

ryanofsky and others added 4 commits August 4, 2024 06:42
Make special cases explicit in GetLogCategory() and LogCategoryToStr()
functions. Simplify the LOG_CATEGORIES_BY_STR and LOG_CATEGORIES_BY_FLAG
mappings and LogCategoriesList() function.

This makes the maps `LOG_CATEGORIES_BY_STR` and `LOG_CATEGORIES_BY_FLAG`
consistent (one is exactly the opposite of the other).
…E instead of 0

* Make the standalone function `LogCategoryToStr()` private inside
  `logging.cpp` (aka `static`) - it is only used in that file.

* Make the method `Logger::GetLogPrefix()` `private` - it is only
  used within the class.

* Use `BCLog::NONE` to initialize `m_categories` instead of `0`.
  We later check whether it is `BCLog::NONE` (in
  `Logger::DefaultShrinkDebugFile()`).
Current logging RPC method documentation claims to accept "0" and "none"
categories, but the "none" argument is actually rejected and the "0"
argument is ignored. Update the implementation to refuse both
categories, and remove the help text claiming to support them.
@vasild
Copy link
Contributor Author

vasild commented Aug 4, 2024

397211b573...a7432dd6ed: pick #29798 (comment) and #29798 (comment)

@LarryRuane
Copy link
Contributor

ACK a7432dd

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK a7432dd. Only changes since last review are removing dead if statement and adding AJ's suggested -debug and -debugexclude help improvements, which look accurate and much more clear.

@ryanofsky ryanofsky merged commit 55d1994 into bitcoin:master Aug 5, 2024
16 checks passed
@ryanofsky
Copy link
Contributor

Merged with 2 current acks and a stale ack since changes after the stale ack were pretty minor (rebase, dropping dead code, updating help as suggested).

@vasild vasild deleted the logging_cleanup branch August 12, 2024 04:34
@bitcoin bitcoin locked and limited conversation to collaborators Aug 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants