-
Notifications
You must be signed in to change notification settings - Fork 38.7k
logging: Update to new logging API #29231
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
Conversation
|
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. |
|
Depending on how many conflicts drahtbot detects, maybe this should be targeting a merge around 27.0's feature freeze? Many of the log statements in init.cpp could be done at a better level, eg |
|
I don't think updating all the macros is a good idea until the API is finished. |
|
Concept ACK - only 3 conflicts, and none look like priority projects. |
src/validation.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove the useless __func__ when changing the log output anyway?
stickies-v
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 2632d038754d975e76926b7c068309c7aadc82f5
Since we don't have significant merge conflicts I would this support this PR having a non-scripted diff commit to first fix incorrect levels (instead of having to fix and then re-fix) but am okay with this approach too.
Suggested fixes in master...stickies-v:bitcoin:2024-01/fix-log-level-29231 - happy to open a separate pull for it too?
Yeah, I think it is better to change a line of code only once, instead of twice, unless there is a reason to change it twice. |
2632d03 to
1441ab7
Compare
Added these commits |
stickies-v
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1441ab74d6cd40e75f1dba80b68bc4b1791bf667
1441ab7 to
6248ea9
Compare
|
Rebased |
Trying to understand the concept here. What problem does this solve? |
6248ea9 to
8d46bd6
Compare
|
re-ACK 8d46bd6750b47caaf2556f915800c6a22c997bc3 - no change since 1441ab74d6cd40e75f1dba80b68bc4b1791bf667 except for addressing merge conflicts |
|
utACK 8d46bd6 Tangential to this PR:
Otherwise: static void libevent_log_cb(int severity, const char *msg)
{
- BCLog::Level level;
switch (severity) {
case EVENT_LOG_DEBUG:
- level = BCLog::Level::Debug;
+ LogDebug(BCLog::LIBEVENT, "%s\n", msg);
break;
case EVENT_LOG_MSG:
- level = BCLog::Level::Info;
+ LogInfo("%s\n", msg);
break;
case EVENT_LOG_WARN:
- level = BCLog::Level::Warning;
+ LogWarning("%s\n", msg);
break;
default: // EVENT_LOG_ERR and others are mapped to error
- level = BCLog::Level::Error;
+ LogError("%s\n", msg);
break;
}
- LogPrintLevel(BCLog::LIBEVENT, level, "%s\n", msg);
} |
As per doc/developer-notes#logging, LogError should be used for severe problems that require the node to shut down
As per doc/developer-notes#logging, LogWarning should be used for severe problems that do not warrant shutting down the node
-BEGIN VERIFY SCRIPT- sed -i 's/LogPrintLevel(\(BCLog::[^,]*\), BCLog::Level::Debug,/LogDebug(\1,/' src/net_processing.cpp src/dbwrapper.cpp src/net.cpp src/node/txreconciliation.cpp src/validation.cpp -END VERIFY SCRIPT-
Changes log output from: [net:error] Something bad happened to either [error] Something bad happened or, when -loglevelalways=1 is enabled: [all:error] Something bad happened -BEGIN VERIFY SCRIPT- sed -i 's/LogPrintLevel(\(BCLog::[^,]*\), BCLog::Level::Error, */LogError(/' src/net.cpp src/txdb.cpp src/txmempool.cpp -END VERIFY SCRIPT-
Changes log output from: [net:warning] Something problematic happened to either [warning] Something problematic happened or, when -loglevelalways=1 is enabled: [all:warning] Something problematic happened -BEGIN VERIFY SCRIPT- sed -i 's/LogPrintLevel(\(BCLog::[^,]*\), BCLog::Level::Warning, */LogWarning(/' src/net.cpp src/node/blockstorage.cpp src/validation.cpp -END VERIFY SCRIPT-
-BEGIN VERIFY SCRIPT- sed -i 's/LogPrint(\(BCLog::[^,]*\),/LogDebug(\1,/' src/init.cpp sed -i 's/LogPrintf(/LogInfo(/' src/init.cpp -END VERIFY SCRIPT-
8d46bd6 to
fd97be4
Compare
|
Rebased over #28834, removed redundancy from |
|
@ajtowns Sorry, i didn't mean to derail this, i shouldn't have commented. |
fae3a1f log: use error level for critical log messages (MarcoFalke) Pull request description: This picks up the first commit from #29231, but extends it to also cover cases that were missed in it. As per https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#logging, LogError should be used for severe problems that require the node to shut down. ACKs for top commit: stickies-v: re-ACK fae3a1f, I'm ~0 on the latest force push as `user_error` was already logged at the right level through `GetNotifications().fatalError(user_error);` so I'd be in favour of deduplicating/cleaning up this logging logic but can be done in follow-up. kevkevinpal: ACK [fae3a1f](fae3a1f) achow101: ACK fae3a1f Tree-SHA512: 3f99fd25d5a204d570a42d8fb2b450439aad7685692f9594cc813d97253c4df172a6ff3cf818959bfcf25dfcf8ee9a9c9ccc6028fcfcecdb47591e18c77ef246
Updates various logging calls to the new API from #28318. All commits are scripted diffs, so should be easy to update if needed, and also easy to reuse the scripts to update other code if needed when rebasing it after this is merged. Changes all uses of
LogPrintLevel()where the level is hardcoded, and changes allLogPrintfandLogPrintuses in init.cpp.