Skip to content

Commit 538497b

Browse files
committed
Merge bitcoin/bitcoin#30255: log: use error level for critical log messages
fae3a1f log: use error level for critical log messages (MarcoFalke) Pull request description: This picks up the first commit from bitcoin/bitcoin#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](bitcoin/bitcoin@fae3a1f) achow101: ACK fae3a1f Tree-SHA512: 3f99fd25d5a204d570a42d8fb2b450439aad7685692f9594cc813d97253c4df172a6ff3cf818959bfcf25dfcf8ee9a9c9ccc6028fcfcecdb47591e18c77ef246
2 parents 0b94fb8 + fae3a1f commit 538497b

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/coins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static bool ExecuteBackedWrapper(Func func, const std::vector<std::function<void
361361
for (const auto& f : err_callbacks) {
362362
f();
363363
}
364-
LogPrintf("Error reading from database: %s\n", e.what());
364+
LogError("Error reading from database: %s\n", e.what());
365365
// Starting the shutdown sequence and returning false to the caller would be
366366
// interpreted as 'entry not found' (as opposed to unable to read data), and
367367
// could lead to invalid interpretation. Just exit immediately, as we can't

src/init.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ static void HandleSIGHUP(int)
409409
static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
410410
{
411411
if (!(*Assert(g_shutdown))()) {
412-
LogPrintf("Error: failed to send shutdown signal on Ctrl-C\n");
412+
LogError("Failed to send shutdown signal on Ctrl-C\n");
413413
return false;
414414
}
415415
Sleep(INFINITE);
@@ -840,7 +840,7 @@ std::set<BlockFilterType> g_enabled_filter_types;
840840
// Since LogPrintf may itself allocate memory, set the handler directly
841841
// to terminate first.
842842
std::set_new_handler(std::terminate);
843-
LogPrintf("Error: Out of memory. Terminating.\n");
843+
LogError("Out of memory. Terminating.\n");
844844

845845
// The log was successful, terminate now.
846846
std::terminate();
@@ -1175,9 +1175,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
11751175
scheduler.scheduleEvery([&args, &node]{
11761176
constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
11771177
if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
1178-
LogPrintf("Shutting down due to lack of disk space!\n");
1178+
LogError("Shutting down due to lack of disk space!\n");
11791179
if (!(*Assert(node.shutdown))()) {
1180-
LogPrintf("Error: failed to send shutdown signal after disk space check\n");
1180+
LogError("Failed to send shutdown signal after disk space check\n");
11811181
}
11821182
}
11831183
}, std::chrono::minutes{5});
@@ -1582,7 +1582,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15821582
try {
15831583
return f();
15841584
} catch (const std::exception& e) {
1585-
LogPrintf("%s\n", e.what());
1585+
LogError("%s\n", e.what());
15861586
return std::make_tuple(node::ChainstateLoadStatus::FAILURE, _("Error opening block database"));
15871587
}
15881588
};
@@ -1614,10 +1614,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16141614
if (fRet) {
16151615
do_reindex = true;
16161616
if (!Assert(node.shutdown)->reset()) {
1617-
LogPrintf("Internal error: failed to reset shutdown signal.\n");
1617+
LogError("Internal error: failed to reset shutdown signal.\n");
16181618
}
16191619
} else {
1620-
LogPrintf("Aborted block database rebuild. Exiting.\n");
1620+
LogError("Aborted block database rebuild. Exiting.\n");
16211621
return false;
16221622
}
16231623
} else {
@@ -1752,7 +1752,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
17521752
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
17531753
LogPrintf("Stopping after block import\n");
17541754
if (!(*Assert(node.shutdown))()) {
1755-
LogPrintf("Error: failed to send shutdown signal after finishing block import\n");
1755+
LogError("Failed to send shutdown signal after finishing block import\n");
17561756
}
17571757
return;
17581758
}

src/node/interfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class NodeImpl : public Node
125125
void startShutdown() override
126126
{
127127
if (!(*Assert(Assert(m_context)->shutdown))()) {
128-
LogPrintf("Error: failed to send shutdown signal\n");
128+
LogError("Failed to send shutdown signal\n");
129129
}
130130
// Stop RPC for clean shutdown if any of waitfor* commands is executed.
131131
if (args().GetBoolArg("-server", false)) {

src/node/kernel_notifications.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state
6363
uiInterface.NotifyBlockTip(state, &index);
6464
if (m_stop_at_height && index.nHeight >= m_stop_at_height) {
6565
if (!m_shutdown()) {
66-
LogPrintf("Error: failed to send shutdown signal after reaching stop height\n");
66+
LogError("Failed to send shutdown signal after reaching stop height\n");
6767
}
6868
return kernel::Interrupted{};
6969
}

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5967,8 +5967,8 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
59675967
PACKAGE_NAME, snapshot_tip_height, snapshot_base_height, snapshot_base_height, PACKAGE_BUGREPORT
59685968
);
59695969

5970-
LogPrintf("[snapshot] !!! %s\n", user_error.original);
5971-
LogPrintf("[snapshot] deleting snapshot, reverting to validated chain, and stopping node\n");
5970+
LogError("[snapshot] !!! %s\n", user_error.original);
5971+
LogError("[snapshot] deleting snapshot, reverting to validated chain, and stopping node\n");
59725972

59735973
m_active_chainstate = m_ibd_chainstate.get();
59745974
m_snapshot_chainstate->m_disabled = true;
@@ -6320,7 +6320,7 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
63206320
fs::path p_old,
63216321
fs::path p_new,
63226322
const fs::filesystem_error& err) {
6323-
LogPrintf("Error renaming path (%s) -> (%s): %s\n",
6323+
LogError("[snapshot] Error renaming path (%s) -> (%s): %s\n",
63246324
fs::PathToString(p_old), fs::PathToString(p_new), err.what());
63256325
GetNotifications().fatalError(strprintf(_(
63266326
"Rename of '%s' -> '%s' failed. "

0 commit comments

Comments
 (0)