mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-01 20:56:42 +09:00
* 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:
1 parent
60bbfde221
commit
d19024969f
13 files changed
+184
-66
No files matched your search
+5
-5
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user