mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
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>
This commit is contained in:
parent
cad127235e
commit
fae3a1f006
5 changed files with 14 additions and 14 deletions
|
@ -361,7 +361,7 @@ static bool ExecuteBackedWrapper(Func func, const std::vector<std::function<void
|
||||||
for (const auto& f : err_callbacks) {
|
for (const auto& f : err_callbacks) {
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
LogPrintf("Error reading from database: %s\n", e.what());
|
LogError("Error reading from database: %s\n", e.what());
|
||||||
// Starting the shutdown sequence and returning false to the caller would be
|
// Starting the shutdown sequence and returning false to the caller would be
|
||||||
// interpreted as 'entry not found' (as opposed to unable to read data), and
|
// interpreted as 'entry not found' (as opposed to unable to read data), and
|
||||||
// could lead to invalid interpretation. Just exit immediately, as we can't
|
// could lead to invalid interpretation. Just exit immediately, as we can't
|
||||||
|
|
16
src/init.cpp
16
src/init.cpp
|
@ -403,7 +403,7 @@ static void HandleSIGHUP(int)
|
||||||
static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
|
static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
|
||||||
{
|
{
|
||||||
if (!(*Assert(g_shutdown))()) {
|
if (!(*Assert(g_shutdown))()) {
|
||||||
LogPrintf("Error: failed to send shutdown signal on Ctrl-C\n");
|
LogError("Failed to send shutdown signal on Ctrl-C\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Sleep(INFINITE);
|
Sleep(INFINITE);
|
||||||
|
@ -834,7 +834,7 @@ std::set<BlockFilterType> g_enabled_filter_types;
|
||||||
// Since LogPrintf may itself allocate memory, set the handler directly
|
// Since LogPrintf may itself allocate memory, set the handler directly
|
||||||
// to terminate first.
|
// to terminate first.
|
||||||
std::set_new_handler(std::terminate);
|
std::set_new_handler(std::terminate);
|
||||||
LogPrintf("Error: Out of memory. Terminating.\n");
|
LogError("Out of memory. Terminating.\n");
|
||||||
|
|
||||||
// The log was successful, terminate now.
|
// The log was successful, terminate now.
|
||||||
std::terminate();
|
std::terminate();
|
||||||
|
@ -1169,9 +1169,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
scheduler.scheduleEvery([&args, &node]{
|
scheduler.scheduleEvery([&args, &node]{
|
||||||
constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
|
constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
|
||||||
if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
|
if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
|
||||||
LogPrintf("Shutting down due to lack of disk space!\n");
|
LogError("Shutting down due to lack of disk space!\n");
|
||||||
if (!(*Assert(node.shutdown))()) {
|
if (!(*Assert(node.shutdown))()) {
|
||||||
LogPrintf("Error: failed to send shutdown signal after disk space check\n");
|
LogError("Failed to send shutdown signal after disk space check\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, std::chrono::minutes{5});
|
}, std::chrono::minutes{5});
|
||||||
|
@ -1576,7 +1576,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
try {
|
try {
|
||||||
return f();
|
return f();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LogPrintf("%s\n", e.what());
|
LogError("%s\n", e.what());
|
||||||
return std::make_tuple(node::ChainstateLoadStatus::FAILURE, _("Error opening block database"));
|
return std::make_tuple(node::ChainstateLoadStatus::FAILURE, _("Error opening block database"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1608,10 +1608,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
if (fRet) {
|
if (fRet) {
|
||||||
chainman.m_blockman.m_reindexing = true;
|
chainman.m_blockman.m_reindexing = true;
|
||||||
if (!Assert(node.shutdown)->reset()) {
|
if (!Assert(node.shutdown)->reset()) {
|
||||||
LogPrintf("Internal error: failed to reset shutdown signal.\n");
|
LogError("Internal error: failed to reset shutdown signal.\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("Aborted block database rebuild. Exiting.\n");
|
LogError("Aborted block database rebuild. Exiting.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1746,7 +1746,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||||
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
|
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
|
||||||
LogPrintf("Stopping after block import\n");
|
LogPrintf("Stopping after block import\n");
|
||||||
if (!(*Assert(node.shutdown))()) {
|
if (!(*Assert(node.shutdown))()) {
|
||||||
LogPrintf("Error: failed to send shutdown signal after finishing block import\n");
|
LogError("Failed to send shutdown signal after finishing block import\n");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public:
|
||||||
void startShutdown() override
|
void startShutdown() override
|
||||||
{
|
{
|
||||||
if (!(*Assert(Assert(m_context)->shutdown))()) {
|
if (!(*Assert(Assert(m_context)->shutdown))()) {
|
||||||
LogPrintf("Error: failed to send shutdown signal\n");
|
LogError("Failed to send shutdown signal\n");
|
||||||
}
|
}
|
||||||
// Stop RPC for clean shutdown if any of waitfor* commands is executed.
|
// Stop RPC for clean shutdown if any of waitfor* commands is executed.
|
||||||
if (args().GetBoolArg("-server", false)) {
|
if (args().GetBoolArg("-server", false)) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state
|
||||||
uiInterface.NotifyBlockTip(state, &index);
|
uiInterface.NotifyBlockTip(state, &index);
|
||||||
if (m_stop_at_height && index.nHeight >= m_stop_at_height) {
|
if (m_stop_at_height && index.nHeight >= m_stop_at_height) {
|
||||||
if (!m_shutdown()) {
|
if (!m_shutdown()) {
|
||||||
LogPrintf("Error: failed to send shutdown signal after reaching stop height\n");
|
LogError("Failed to send shutdown signal after reaching stop height\n");
|
||||||
}
|
}
|
||||||
return kernel::Interrupted{};
|
return kernel::Interrupted{};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5950,8 +5950,8 @@ SnapshotCompletionResult ChainstateManager::MaybeCompleteSnapshotValidation()
|
||||||
PACKAGE_NAME, snapshot_tip_height, snapshot_base_height, snapshot_base_height, PACKAGE_BUGREPORT
|
PACKAGE_NAME, snapshot_tip_height, snapshot_base_height, snapshot_base_height, PACKAGE_BUGREPORT
|
||||||
);
|
);
|
||||||
|
|
||||||
LogPrintf("[snapshot] !!! %s\n", user_error.original);
|
LogError("[snapshot] !!! %s\n", user_error.original);
|
||||||
LogPrintf("[snapshot] deleting snapshot, reverting to validated chain, and stopping node\n");
|
LogError("[snapshot] deleting snapshot, reverting to validated chain, and stopping node\n");
|
||||||
|
|
||||||
m_active_chainstate = m_ibd_chainstate.get();
|
m_active_chainstate = m_ibd_chainstate.get();
|
||||||
m_snapshot_chainstate->m_disabled = true;
|
m_snapshot_chainstate->m_disabled = true;
|
||||||
|
@ -6303,7 +6303,7 @@ bool ChainstateManager::ValidatedSnapshotCleanup()
|
||||||
fs::path p_old,
|
fs::path p_old,
|
||||||
fs::path p_new,
|
fs::path p_new,
|
||||||
const fs::filesystem_error& err) {
|
const fs::filesystem_error& err) {
|
||||||
LogPrintf("Error renaming path (%s) -> (%s): %s\n",
|
LogError("[snapshot] Error renaming path (%s) -> (%s): %s\n",
|
||||||
fs::PathToString(p_old), fs::PathToString(p_new), err.what());
|
fs::PathToString(p_old), fs::PathToString(p_new), err.what());
|
||||||
GetNotifications().fatalError(strprintf(_(
|
GetNotifications().fatalError(strprintf(_(
|
||||||
"Rename of '%s' -> '%s' failed. "
|
"Rename of '%s' -> '%s' failed. "
|
||||||
|
|
Loading…
Add table
Reference in a new issue