Skip to content

util/log: Combine the warning/error log levels into a single alert level#34730

Draft
ajtowns wants to merge 2 commits intobitcoin:masterfrom
ajtowns:202603-logalert
Draft

util/log: Combine the warning/error log levels into a single alert level#34730
ajtowns wants to merge 2 commits intobitcoin:masterfrom
ajtowns:202603-logalert

Conversation

@ajtowns
Copy link
Contributor

@ajtowns ajtowns commented Mar 4, 2026

There's little benefit in having two error levels that the node operator should pay attention to when the only difference between them is that one means the node is about to shut down -- the admin can easily see that just by looking at whether the node did shutdown. So this PR replaces LogWarning and LogError with LogAlert, which hopefully emphasises that the point of using that level is to alert the node operator.

Leaves LogWarning and LogError available as deprecated aliases to reduce code churn and avoid invalidating PRs.

Left as draft pending #34038 as the "warning" and "error" levels are currently exposed to users via the -loglevel config option.

ajtowns added 2 commits March 4, 2026 20:46
-BEGIN VERIFY SCRIPT-
sed -i 's/LogWarning(/LogAlert(/g; s/LogError(/LogAlert(/g; s/\(LogAlert("[^\"]*\)\\n\("[,)]\)/\1\2/g' src/node/blockstorage.cpp
-END VERIFY SCRIPT-
@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 4, 2026

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ryanofsky

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34806 (refactor: logging: Various API improvements by ajtowns)
  • #34778 (logging: rewrite macros to add ratelimit option, avoid unused strprintf, clarify confusing errors by ryanofsky)
  • #30361 (doc: Drop description of LogError messages as fatal by ryanofsky)
  • #29256 (log, refactor: Allow log macros to accept context arguments 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.

@ajtowns
Copy link
Contributor Author

ajtowns commented Mar 4, 2026

Previous discussion: #30348 and #30364

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 4ce720b. Concept -0.

This PR is definitely not the change I would make, but it seems fine and helps decrease the gap between way the macros are actually used and the way they were originally intended to be used.

IMO, a more ideal solution would:

  1. Keep the error and warning levels instead of removing them, because [error] [warning] tags shown in log output are helpful for distinguishing actual problems from potential problems from informational messages.
  2. Make error and warning log levels conditional (users can configure whether messages are logged) instead of unconditional.
  3. Introduce a new "critical" level and LogCritical macro which is unconditional and always logs even when debug logging is turned off. To me "critical" sounds more negative and "alert" sounds more fake like "Alert! Walmart's prices are lower than competitors". But obviously the word choice is not important.

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