Skip to content

Commit fae3a1f

Browse files
MarcoFalkestickies-v
andcommitted
log: use error level for critical log messages
As per doc/developer-notes#logging, LogError should be used for severe problems that require the node to shut down. Co-Authored-By: stickies-v <stickies-v@protonmail.com>
1 parent cad1272 commit fae3a1f

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
@@ -403,7 +403,7 @@ static void HandleSIGHUP(int)
403403
static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
404404
{
405405
if (!(*Assert(g_shutdown))()) {
406-
LogPrintf("Error: failed to send shutdown signal on Ctrl-C\n");
406+
LogError("Failed to send shutdown signal on Ctrl-C\n");
407407
return false;
408408
}
409409
Sleep(INFINITE);
@@ -834,7 +834,7 @@ std::set<BlockFilterType> g_enabled_filter_types;
834834
// Since LogPrintf may itself allocate memory, set the handler directly
835835
// to terminate first.
836836
std::set_new_handler(std::terminate);
837-
LogPrintf("Error: Out of memory. Terminating.\n");
837+
LogError("Out of memory. Terminating.\n");
838838

839839
// The log was successful, terminate now.
840840
std::terminate();
@@ -1169,9 +1169,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
11691169
scheduler.scheduleEvery([&args, &node]{
11701170
constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
11711171
if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
1172-
LogPrintf("Shutting down due to lack of disk space!\n");
1172+
LogError("Shutting down due to lack of disk space!\n");
11731173
if (!(*Assert(node.shutdown))()) {
1174-
LogPrintf("Error: failed to send shutdown signal after disk space check\n");
1174+
LogError("Failed to send shutdown signal after disk space check\n");
11751175
}
11761176
}
11771177
}, std::chrono::minutes{5});
@@ -1576,7 +1576,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15761576
try {
15771577
return f();
15781578
} catch (const std::exception& e) {
1579-
LogPrintf("%s\n", e.what());
1579+
LogError("%s\n", e.what());
15801580
return std::make_tuple(node::ChainstateLoadStatus::FAILURE, _("Error opening block database"));
15811581
}
15821582
};
@@ -1608,10 +1608,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16081608
if (fRet) {
16091609
chainman.m_blockman.m_reindexing = true;
16101610
if (!Assert(node.shutdown)->reset()) {
1611-
LogPrintf("Internal error: failed to reset shutdown signal.\n");
1611+
LogError("Internal error: failed to reset shutdown signal.\n");
16121612
}
16131613
} else {
1614-
LogPrintf("Aborted block database rebuild. Exiting.\n");
1614+
LogError("Aborted block database rebuild. Exiting.\n");
16151615
return false;
16161616
}
16171617
} else {
@@ -1746,7 +1746,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
17461746
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
17471747
LogPrintf("Stopping after block import\n");
17481748
if (!(*Assert(node.shutdown))()) {
1749-
LogPrintf("Error: failed to send shutdown signal after finishing block import\n");
1749+
LogError("Failed to send shutdown signal after finishing block import\n");
17501750
}
17511751
return;
17521752
}

src/node/interfaces.cpp

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

src/node/kernel_notifications.cpp

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

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5950,8 +5950,8 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
59505950
PACKAGE_NAME, snapshot_tip_height, snapshot_base_height, snapshot_base_height, PACKAGE_BUGREPORT
59515951
);
59525952

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

59565956
m_active_chainstate = m_ibd_chainstate.get();
59575957
m_snapshot_chainstate->m_disabled = true;
@@ -6303,7 +6303,7 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
63036303
fs::path p_old,
63046304
fs::path p_new,
63056305
const fs::filesystem_error& err) {
6306-
LogPrintf("Error renaming path (%s) -> (%s): %s\n",
6306+
LogError("[snapshot] Error renaming path (%s) -> (%s): %s\n",
63076307
fs::PathToString(p_old), fs::PathToString(p_new), err.what());
63086308
GetNotifications().fatalError(strprintf(_(
63096309
"Rename of '%s' -> '%s' failed. "

0 commit comments

Comments
 (0)