8000 Severity-based logging -- parent PR by jonatack · Pull Request #25203 · bitcoin/bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Severity-based logging -- parent PR #25203

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

Closed
wants to merge 22 commits into from

Conversation

jonatack
Copy link
Member
@jonatack jonatack commented May 24, 2022

This is a parent PR for continuing updates to severity-based logging. See #20576 for motivation and #25306 for discussion.

@jonatack jonatack changed the title log: de-dupe TOR/I2P/NET category prefixes and update their LogPrintf ones log: de-duplicate logging category output May 24, 2022
@jonatack jonatack changed the title log: de-duplicate logging category output log: de-duplicate categories, use severity-based logging for torcontrol/i2p/netbase May 25, 2022
@jonatack
Copy link
Member Author
jonatack commented May 25, 2022

This partially depends on #25202 and needs to be updated after the merge of that PR for the change in refactor: Change LogPrintLevel order to category, severity, so leaving in draft for now.

@DrahtBot
Copy link
Contributor
DrahtBot commented May 26, 2022

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
Concept ACK laanwj, maflcko
Approach ACK klementtan, w0xlt, vasild

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:

  • #25683 (refactor: log nEvicted message in LimitOrphans then return void by chinggg)
  • #25678 (p2p: skip querying dns seeds if -onlynet disables IPv4 and IPv6 by mzumsande)
  • #25673 (refactor: make member functions const when applicable by aureleoules)
  • #25619 (net: avoid overriding non-virtual ToString() in CService and use better naming by vasild)
  • #25614 (logging: add -loglevel configuration option and a trace log level by jonatack)
  • #25555 (refactor: Move m_num_unconnecting_headers_msgs out of cs_main guard by MarcoFalke)
  • #25499 (Use steady clock for all millis bench logging by MarcoFalke)
  • #25421 (net: convert standalone IsSelectableSocket() and SetSocketNonBlocking() to Sock methods by vasild)
  • #25390 (sync: introduce a thread-safe smart container and use it to remove a bunch of "GlobalMutex"es by vasild)
  • #25355 (I2P: add support for transient addresses for outbound connections by vasild)
  • #25284 ([WIP] consensus: Remove dependency on net (BIP 155 / ADDRV2_FORMAT) by MarcoFalke)
  • #25172 (refactor: use std:: prefix for std lib funcs by fanquake)
  • #25136 (Torcontrol opt check by amadeuszpawlik)
  • #25077 (Fix chain tip data race and corrupt rest response by MarcoFalke)
  • #25038 (policy: nVersion=3 and Package RBF by glozow)
  • #24974 (refactor: Make FEELER_SLEEP_WINDOW type safe (std::chrono) by MarcoFalke)
  • #24950 (Add config option to set max debug log size by tehelsper)
  • #24697 (refactor address relay time by MarcoFalke)
  • #24606 (Change -maxtimeadjustment default from 70 minutes to 0 by jonatack)
  • #24571 (p2p: Prevent block index fingerprinting by sending additional getheaders messages by dergoegge)
  • #23605 (util: Add TorControlArgumentCheck function by shaavan)
  • #21878 (Make all networking code mockable by vasild)

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.

@DrahtBot DrahtBot mentioned this pull request May 26, 2022
@jonatack jonatack force-pushed the logging-updates branch 3 times, most recently from c1b9fe7 to bbf52db Compare May 26, 2022 16:53
@jonatack jonatack changed the title log: de-duplicate categories, use severity-based logging for torcontrol/i2p/netbase log: dedup categories, add macro, use severity-based logging for tor/i2p/netbase May 26, 2022
@DrahtBot DrahtBot mentioned this pull request May 29, 2022
12 tasks
@jonatack jonatack changed the title log: dedup categories, add macro, use severity-based logging fo 10000 r tor/i2p/netbase log: dedup categories, add macro, use severity-based logging Jun 2, 2022
@jonatack jonatack changed the title log: dedup categories, add macro, use severity-based logging logging: update to severity-based logging Jun 2, 2022
@jonatack jonatack marked this pull request as ready for review June 2, 2022 15:30
@jonatack jonatack force-pushed the logging-updates branch 2 times, most recently from ea89754 to 3168b62 Compare June 2, 2022 17:56
LogPrint(BCLog::NET, "Large reorg, won't direct fetch to %s (%d)\n",
pindexLast->GetBlockHash().ToString(),
pindexLast->nHeight);
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "Large reorg, won't direct fetch to %s (%d)\n",
Copy link
Member

Choose a reason for hiding this comment

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

Is the switch to unconditional logging intended here?

If yes, then it's probably better done in a separate commit because it is not immediately clear that this is safe and it's quite easy to miss mixed in with all the other changes in this commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good point that any changes from conditional to unconditional logging should be separated out.

if (level >= BCLog::Level::Warning) return true;
// Log the Info, Warning, and Error message levels unconditionally, so that
// important troubleshooting information isn't lost.
if (level >= BCLog::Level::Info) return true;
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this almost deserves its own PR (maybe you are already planning on doing so). afaict we don't log anything right now using Info which is the only reason this change is safe but that might not be clear to reviewers of this rather large PR. (If for example we had a lot of log locations using Info then they would all need to be revisited w.r.t. to disk filling attacks)

< 8000 /div>
Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. My original thinking was that info would be conditional like debug and trace and that only warning and error would be unconditional, which would also reduce the volume of default logging. However, that changed during the discussions in #25306. Will keep your suggestion in mind while restructuring the update here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Noting here that this change was done in #28318, resolving.

@achow101 achow101 marked this pull request as draft October 12, 2022 19:22
@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@jonatack
Copy link
Member Author

Updating and rebasing.

@ajtowns
Copy link
Contributor
ajtowns commented Jan 23, 2023

I guess I've got conceptual questions about this.

  1. It seems very intrusive to change LogPrint(NET, "hi"); to LogPrintLevel(NET, DEBUG, "hi"); everywhere. Why not just make LogPrint default to DEBUG instead of NONE and keep things brief? Likewise, why have LogPrintLevel(INFO) instead of just LogInfo and LogWarning etc?
  2. Why is m_category_log_levels a map guarded by a mutex? We only have three levels: tracing, debugging and unconditional -- why not just have two atomic bitfields: m_trace_categories and m_debug_categories. Then your test is:
if (level == TRACE) return (m_trace_categories.load(relaxed) & category) != 0;
else if (level == DEBUG) return (m_debug_categories.load(relaxed) & category) != 0;
else return true;
  1. [EDIT to add] I guess it's not clear to me why you'd ever want to say LogPrintLevel(NET, INFO, "foo") rather than LogPrintf("foo")? I guess in general, if the logging is unconditional anyway, I don't see what value there is in associating it with a category; likewise, adding a warning/error/debug/trace tag seems useful, but an "info" tag doesn't seem useful? So having LogPrintf(msg) ; LogWarning(msg) ; LogError(msg) ; LogPrint(CATEGORY, msg) ; LogTrace(CATEGORY, msg) would make more sense to me (maybe deprecating LogPrintf in favour of LogInfo or similar over time, eventually with a scripted-diff to finish off)

@jonatack
Copy link
Member Author

Thanks for the detailed feedback, @ajtowns. Will update with it in mind; looks like it will be helpful in simplifying things.

@jonatack jonatack mentioned this pull request Mar 20, 2023
achow101 added a commit that referenced this pull request Mar 23, 2023
8c47d59 doc: improve -debuglogfile help to be a bit clearer (jonatack)
20d89d6 bench: document expected results in logging benchmarks (jonatack)
d8deba8 bench: add LogPrintfCategory and LogPrintLevel benchmarks (Jon Atack)
102b203 bench: order the logging benchmark code by output (Jon Atack)
4b3fdbf bench: update logging benchmark naming for clarity (Jon Atack)
4684aa8 bench: allow logging benchmarks to be order-independent (Larry Ruane)

Pull request description:

  Update our logging benchmarks for evaluating ongoing work like #25203 and refactoring proposals like #26619 and #26697.

  - make the logging benchmarks order-independent (Larry Ruane)
  - add missing benchmarks for the `LogPrintLevel` and `LogPrintfCategory` macros that our logging is migrating to; at some later point it should be feasible to drop some of the previous logging benchmarks
  - update the logging benchmark naming to be clear which benchmark corresponds to which log macro, and update the ordering to be the same as the output
  - add clarifying documentation to the logging benchmarks
  - improve the `-debuglogfile` config option help to be clearer; can be tested by running `./src/bitcoind -help | grep -A4 '\-debuglogfile'`

  Reviewers can run the logging benchmarks with:
  ```bash
  ./src/bench/bench_bitcoin -filter='LogP*.*'
  ```

ACKs for top commit:
  LarryRuane:
    ACK 8c47d59
  martinus:
    code review & tested ACK 8c47d59, here are my benchmark results:
  achow101:
    ACK 8c47d59

Tree-SHA512: 705f8720c9ceaf14a1945039c7578a0c17a12215cbc44908099af4ac444561c3f95d833c5a91b325cdd4470737d8a01e2da64db2d542dd7c9a3747fbfdbf213e
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 24, 2023
8c47d59 doc: improve -debuglogfile help to be a bit clearer (jonatack)
20d89d6 bench: document expected results in logging benchmarks (jonatack)
d8deba8 bench: add LogPrintfCategory and LogPrintLevel benchmarks (Jon Atack)
102b203 bench: order the logging benchmark code by output (Jon Atack)
4b3fdbf bench: update logging benchmark naming for clarity (Jon Atack)
4684aa8 bench: allow logging benchmarks to be order-independent (Larry Ruane)

Pull request description:

  Update our logging benchmarks for evaluating ongoing work like bitcoin#25203 and refactoring proposals like bitcoin#26619 and bitcoin#26697.

  - make the logging benchmarks order-independent (Larry Ruane)
  - add missing benchmarks for the `LogPrintLevel` and `LogPrintfCategory` macros that our logging is migrating to; at some later point it should be feasible to drop some of the previous logging benchmarks
  - update the logging benchmark naming to be clear which benchmark corresponds to which log macro, and update the ordering to be the same as the output
  - add clarifying documentation to the logging benchmarks
  - improve the `-debuglogfile` config option help to be clearer; can be tested by running `./src/bitcoind -help | grep -A4 '\-debuglogfile'`

  Reviewers can run the logging benchmarks with:
  ```bash
  ./src/bench/bench_bitcoin -filter='LogP*.*'
  ```

ACKs for top commit:
  LarryRuane:
    ACK 8c47d59
  martinus:
    code review & tested ACK 8c47d59, here are my benchmark results:
  achow101:
    ACK 8c47d59

Tree-SHA512: 705f8720c9ceaf14a1945039c7578a0c17a12215cbc44908099af4ac444561c3f95d833c5a91b325cdd4470737d8a01e2da64db2d542dd7c9a3747fbfdbf213e
@jonatack
Copy link
Member Author

Closing temporarily so that I can re-open it -- am still interested to finish this.

@jonatack
Copy link
Member Author
jonatack commented Aug 31, 2023

Have been waiting for bugfix #27231 to be merged to update here, but it seems useful to re-open it before so that people are aware of it. Given how long the bugfix has been open, I'll propose further non-conflicting steps from this parent without waiting further.

@jonatack
Copy link
Member Author
jonatack commented Aug 31, 2023

Why not just make LogPrint default to DEBUG instead of NONE

Much of the added value from moving to severity-level logging IMO comes from splitting LogPrint to trace or debug (so, non-automatically), e.g. for net logging, noisy high-frequency low-level p2p messages in this parent become trace, and lower-frequency, high-level events like peer disconnect/discourage become debug.

I guess it's not clear to me why you'd ever want to say LogPrintLevel(NET, INFO, "foo") rather than LogPrintf("foo")? I guess in general, if the logging is unconditional anyway, I don't see what value there is in associating it with a category

"info" tag doesn't seem useful?

Consistency and least astonishment, which is clearer for regular users.

Logging the category for error vs warning vs info seems useful to me. Perhaps I misunderstand your comment.

maybe deprecating LogPrintf in favour of LogInfo or similar over time, eventually with a scripted-diff to finish off

The idea is for Log(category, level) to subsume all the other macros, to have just one.

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

fanquake added a commit that referenced this pull request Jan 16, 2024
…logged levels

ec779a2 doc: add unconditional info loglevel following merge of PR 28318 (Jon Atack)

Pull request description:

  Commit ab34dc6 of #28318 was an incomplete version of [`118c756` (#25203)](118c756) from the `Severity-based logging` parent PR.

  Add the missing text to update the `-loglevel` help doc.

  While here, make the help text a little easier to understand.

  Can be tested by running:

  ```
  ./src/bitcoind -regtest -help-debug | grep -A12 loglevel=
  ```

  before
  ```
    -loglevel=<level>|<category>:<level>
         Set the global or per-category severity level for logging categories
         enabled with the -debug configuration option or the logging RPC:
         info, debug, trace (default=debug); warning and error levels are
         always logged.
  ```

  after
  ```
    -loglevel=<level>|<category>:<level>
         Set the global or per-category severity level for logging categories
         enabled with the -debug configuration option or the logging RPC.
         Possible values are info, debug, trace (default=debug). The
         following levels are always logged: error, warning, info.
  ```

ACKs for top commit:
  stickies-v:
    ACK ec779a2

Tree-SHA512: 0c375e30a5a4c168ca7d97720e8c287f598216767afedae329824e09a480830faf8537b792c5c4bb647c68681c287fe3005c62093708ce85624e9a71c8245e42
@jonatack
Copy link
Member Author
jonatack commented Apr 8, 2024

Closing to be able to re-open it.

@jonatack jonatack closed this Apr 8, 2024
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 17, 2025
…always logged levels

ec779a2 doc: add unconditional info loglevel following merge of PR 28318 (Jon Atack)

Pull request description:

  Commit ab34dc6 of bitcoin#28318 was an incomplete version of [`118c756` (bitcoin#25203)](bitcoin@118c756) from the `Severity-based logging` parent PR.

  Add the missing text to update the `-loglevel` help doc.

  While here, make the help text a little easier to understand.

  Can be tested by running:

  ```
  ./src/bitcoind -regtest -help-debug | grep -A12 loglevel=
  ```

  before
  ```
    -loglevel=<level>|<category>:<level>
         Set the global or per-category severity level for logging categories
         enabled with the -debug configuration option or the logging RPC:
         info, debug, trace (default=debug); warning and error levels are
         always logged.
  ```

  after
  ```
    -loglevel=<level>|<category>:<level>
         Set the global or per-category severity level for logging categories
         enabled with the -debug configuration option or the logging RPC.
         Possible values are info, debug, trace (default=debug). The
         following levels are always logged: error, warning, info.
  ```

ACKs for top commit:
  stickies-v:
    ACK ec779a2

Tree-SHA512: 0c375e30a5a4c168ca7d97720e8c287f598216767afedae329824e09a480830faf8537b792c5c4bb647c68681c287fe3005c62093708ce85624e9a71c8245e42
@bitcoin bitcoin locked and limited conversation to collaborators Apr 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants
0