mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
log: Use LogWarning for non-critical logs
As per doc/developer-notes#logging, LogWarning should be used for severe problems that do not warrant shutting down the node
This commit is contained in:
@@ -40,7 +40,7 @@ static void ErrorLogCallback(void* arg, int code, const char* msg)
|
||||
// invoked."
|
||||
// Assert that this is the case:
|
||||
assert(arg == nullptr);
|
||||
LogPrintf("SQLite Error. Code: %d. Message: %s\n", code, msg);
|
||||
LogWarning("SQLite Error. Code: %d. Message: %s", code, msg);
|
||||
}
|
||||
|
||||
static int TraceSqlCallback(unsigned code, void* context, void* param1, void* param2)
|
||||
@@ -69,7 +69,7 @@ static bool BindBlobToStatement(sqlite3_stmt* stmt,
|
||||
// instead of the empty blob value X'', which would mess up SQL comparisons.
|
||||
int res = sqlite3_bind_blob(stmt, index, blob.data() ? static_cast<const void*>(blob.data()) : "", blob.size(), SQLITE_STATIC);
|
||||
if (res != SQLITE_OK) {
|
||||
LogPrintf("Unable to bind %s to statement: %s\n", description, sqlite3_errstr(res));
|
||||
LogWarning("Unable to bind %s to statement: %s", description, sqlite3_errstr(res));
|
||||
sqlite3_clear_bindings(stmt);
|
||||
sqlite3_reset(stmt);
|
||||
return false;
|
||||
@@ -179,7 +179,7 @@ void SQLiteDatabase::Cleanup() noexcept
|
||||
if (--g_sqlite_count == 0) {
|
||||
int ret = sqlite3_shutdown();
|
||||
if (ret != SQLITE_OK) {
|
||||
LogPrintf("SQLiteDatabase: Failed to shutdown SQLite: %s\n", sqlite3_errstr(ret));
|
||||
LogWarning("SQLiteDatabase: Failed to shutdown SQLite: %s", sqlite3_errstr(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ void SQLiteDatabase::Open()
|
||||
if (LogAcceptCategory(BCLog::WALLETDB, BCLog::Level::Trace)) {
|
||||
ret = sqlite3_trace_v2(m_db, SQLITE_TRACE_STMT, TraceSqlCallback, this);
|
||||
if (ret != SQLITE_OK) {
|
||||
LogPrintf("Failed to enable SQL tracing for %s\n", Filename());
|
||||
LogWarning("Failed to enable SQL tracing for %s", Filename());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ void SQLiteDatabase::Open()
|
||||
|
||||
if (m_use_unsafe_sync) {
|
||||
// Use normal synchronous mode for the journal
|
||||
LogPrintf("WARNING SQLite is configured to not wait for data to be flushed to disk. Data loss and corruption may occur.\n");
|
||||
LogWarning("SQLite is configured to not wait for data to be flushed to disk. Data loss and corruption may occur.");
|
||||
SetPragma(m_db, "synchronous", "OFF", "Failed to set synchronous mode to OFF");
|
||||
}
|
||||
|
||||
@@ -350,14 +350,14 @@ bool SQLiteDatabase::Backup(const std::string& dest) const
|
||||
}
|
||||
sqlite3_backup* backup = sqlite3_backup_init(db_copy, "main", m_db, "main");
|
||||
if (!backup) {
|
||||
LogPrintf("%s: Unable to begin backup: %s\n", __func__, sqlite3_errmsg(m_db));
|
||||
LogWarning("Unable to begin sqlite backup: %s", sqlite3_errmsg(m_db));
|
||||
sqlite3_close(db_copy);
|
||||
return false;
|
||||
}
|
||||
// Specifying -1 will copy all of the pages
|
||||
res = sqlite3_backup_step(backup, -1);
|
||||
if (res != SQLITE_DONE) {
|
||||
LogPrintf("%s: Unable to backup: %s\n", __func__, sqlite3_errstr(res));
|
||||
LogWarning("Unable to continue sqlite backup: %s", sqlite3_errstr(res));
|
||||
sqlite3_backup_finish(backup);
|
||||
sqlite3_close(db_copy);
|
||||
return false;
|
||||
@@ -409,13 +409,13 @@ void SQLiteBatch::Close()
|
||||
// If we began a transaction, and it wasn't committed, abort the transaction in progress
|
||||
if (m_txn) {
|
||||
if (TxnAbort()) {
|
||||
LogPrintf("SQLiteBatch: Batch closed unexpectedly without the transaction being explicitly committed or aborted\n");
|
||||
LogWarning("SQLiteBatch: Batch closed unexpectedly without the transaction being explicitly committed or aborted");
|
||||
} else {
|
||||
// If transaction cannot be aborted, it means there is a bug or there has been data corruption. Try to recover in this case
|
||||
// by closing and reopening the database. Closing the database should also ensure that any changes made since the transaction
|
||||
// was opened will be rolled back and future transactions can succeed without committing old data.
|
||||
force_conn_refresh = true;
|
||||
LogPrintf("SQLiteBatch: Batch closed and failed to abort transaction, resetting db connection..\n");
|
||||
LogWarning("SQLiteBatch: Batch closed and failed to abort transaction, resetting db connection..");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ void SQLiteBatch::Close()
|
||||
for (const auto& [stmt_prepared, stmt_description] : statements) {
|
||||
int res = sqlite3_finalize(*stmt_prepared);
|
||||
if (res != SQLITE_OK) {
|
||||
LogPrintf("SQLiteBatch: Batch closed but could not finalize %s statement: %s\n",
|
||||
LogWarning("SQLiteBatch: Batch closed but could not finalize %s statement: %s",
|
||||
stmt_description, sqlite3_errstr(res));
|
||||
}
|
||||
*stmt_prepared = nullptr;
|
||||
@@ -462,7 +462,7 @@ bool SQLiteBatch::ReadKey(DataStream&& key, DataStream& value)
|
||||
if (res != SQLITE_ROW) {
|
||||
if (res != SQLITE_DONE) {
|
||||
// SQLITE_DONE means "not found", don't log an error in that case.
|
||||
LogPrintf("%s: Unable to execute statement: %s\n", __func__, sqlite3_errstr(res));
|
||||
LogWarning("Unable to execute read statement: %s", sqlite3_errstr(res));
|
||||
}
|
||||
sqlite3_clear_bindings(m_read_stmt);
|
||||
sqlite3_reset(m_read_stmt);
|
||||
@@ -502,7 +502,7 @@ bool SQLiteBatch::WriteKey(DataStream&& key, DataStream&& value, bool overwrite)
|
||||
sqlite3_clear_bindings(stmt);
|
||||
sqlite3_reset(stmt);
|
||||
if (res != SQLITE_DONE) {
|
||||
LogPrintf("%s: Unable to execute statement: %s\n", __func__, sqlite3_errstr(res));
|
||||
LogWarning("Unable to execute write statement: %s", sqlite3_errstr(res));
|
||||
}
|
||||
|
||||
if (!m_txn) m_database.m_write_semaphore.release();
|
||||
@@ -526,7 +526,7 @@ bool SQLiteBatch::ExecStatement(sqlite3_stmt* stmt, std::span<const std::byte> b
|
||||
sqlite3_clear_bindings(stmt);
|
||||
sqlite3_reset(stmt);
|
||||
if (res != SQLITE_DONE) {
|
||||
LogPrintf("%s: Unable to execute statement: %s\n", __func__, sqlite3_errstr(res));
|
||||
LogWarning("Unable to execute exec statement: %s", sqlite3_errstr(res));
|
||||
}
|
||||
|
||||
if (!m_txn) m_database.m_write_semaphore.release();
|
||||
@@ -564,7 +564,7 @@ DatabaseCursor::Status SQLiteCursor::Next(DataStream& key, DataStream& value)
|
||||
return Status::DONE;
|
||||
}
|
||||
if (res != SQLITE_ROW) {
|
||||
LogPrintf("%s: Unable to execute cursor step: %s\n", __func__, sqlite3_errstr(res));
|
||||
LogWarning("Unable to execute cursor step: %s", sqlite3_errstr(res));
|
||||
return Status::FAIL;
|
||||
}
|
||||
|
||||
@@ -583,8 +583,8 @@ SQLiteCursor::~SQLiteCursor()
|
||||
sqlite3_reset(m_cursor_stmt);
|
||||
int res = sqlite3_finalize(m_cursor_stmt);
|
||||
if (res != SQLITE_OK) {
|
||||
LogPrintf("%s: cursor closed but could not finalize cursor statement: %s\n",
|
||||
__func__, sqlite3_errstr(res));
|
||||
LogWarning("Cursor closed but could not finalize cursor statement: %s",
|
||||
sqlite3_errstr(res));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ bool SQLiteBatch::TxnBegin()
|
||||
Assert(!m_database.HasActiveTxn());
|
||||
int res = Assert(m_exec_handler)->Exec(m_database, "BEGIN TRANSACTION");
|
||||
if (res != SQLITE_OK) {
|
||||
LogPrintf("SQLiteBatch: Failed to begin the transaction\n");
|
||||
LogWarning("SQLiteBatch: Failed to begin the transaction");
|
||||
m_database.m_write_semaphore.release();
|
||||
} else {
|
||||
m_txn = true;
|
||||
@@ -666,7 +666,7 @@ bool SQLiteBatch::TxnCommit()
|
||||
Assert(m_database.HasActiveTxn());
|
||||
int res = Assert(m_exec_handler)->Exec(m_database, "COMMIT TRANSACTION");
|
||||
if (res != SQLITE_OK) {
|
||||
LogPrintf("SQLiteBatch: Failed to commit the transaction\n");
|
||||
LogWarning("SQLiteBatch: Failed to commit the transaction");
|
||||
} else {
|
||||
m_txn = false;
|
||||
m_database.m_write_semaphore.release();
|
||||
@@ -680,7 +680,7 @@ bool SQLiteBatch::TxnAbort()
|
||||
Assert(m_database.HasActiveTxn());
|
||||
int res = Assert(m_exec_handler)->Exec(m_database, "ROLLBACK TRANSACTION");
|
||||
if (res != SQLITE_OK) {
|
||||
LogPrintf("SQLiteBatch: Failed to abort the transaction\n");
|
||||
LogWarning("SQLiteBatch: Failed to abort the transaction");
|
||||
} else {
|
||||
m_txn = false;
|
||||
m_database.m_write_semaphore.release();
|
||||
|
||||
Reference in New Issue
Block a user