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
logging: Update to new logging API #29231
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. |
@@ -2626,7 +2626,7 @@ bool Chainstate::FlushStateToDisk( | |||
// TODO: Handle return error, or add detailed comment why it is | |||
// safe to not return an error upon failure. | |||
if (!m_blockman.FlushChainstateBlockFile(m_chain.Height())) { | |||
LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Warning, "%s: Failed to flush block file.\n", __func__); | |||
LogWarning("%s: Failed to flush block file.\n", __func__); |
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?
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 2632d03
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 |
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 1441ab7
1441ab7
to
6248ea9
Compare
Rebased |
Trying to understand the concept here. What problem does this solve? |
6248ea9
to
8d46bd6
Compare
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. |
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 allLogPrintf
andLogPrint
uses in init.cpp.