F #7977: Log replication and hearbeats (#4411)

*  Optimize logging of ddebug and dddebug messages. Lazy stream builder: Avoid composing of expensive long strings, if the
message is discardad because of log level
This commit is contained in:
Pavel Czerný authored and GitHub committed 2026-08-26 13:46:35 +02:00
1 parent 60bbfde221
commit d19024969f
13 files changed
+184 -66

No files matched your search

+5 -5
View File
@@ -409,14 +409,14 @@ int MySqlDB::exec_ext(std::ostringstream& cmd, Callbackable *obj, bool quiet)
if (result == NULL)
{
ostringstream oss;
const char * err_msg = mysql_error(db);
int err_num = mysql_errno(db);
oss << "SQL command was: " << c_str;
oss << ", error " << err_num << " : " << err_msg;
NebulaLog::log("ONE", error_level, oss);
NebulaLog::log("ONE", error_level, [&](std::ostream& log)
{
log << "SQL command was: " << c_str << ", error "
<< err_num << " : " << err_msg;
});
free_db_connection(db);
+4 -4
View File
@@ -93,8 +93,6 @@ int SqliteDB::exec_ext(std::ostringstream& cmd, Callbackable *obj, bool quiet)
void * arg;
Log::MessageType error_level;
std::ostringstream oss;
str = cmd.str();
c_str = str.c_str();
@@ -148,8 +146,10 @@ int SqliteDB::exec_ext(std::ostringstream& cmd, Callbackable *obj, bool quiet)
{
error_level = quiet ? Log::DDEBUG : Log::ERROR;
oss << "SQL command was: " << c_str << ", error: " << err_msg;
NebulaLog::log("ONE", error_level, oss);
NebulaLog::log("ONE", error_level, [&](std::ostream& log)
{
log << "SQL command was: " << c_str << ", error: " << err_msg;
});
sqlite3_free(err_msg);
}