diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2018-05-27 19:09:08 +0200 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2018-05-27 19:09:42 +0200 |
commit | 2fd6df0b258dc8dd4bb30da0b8781286d4aac09d (patch) | |
tree | dd60e3714944d5f93187c0de64b1356a604522b3 /src/util/db | |
parent | 012421669b6c773d800c7bb457d91daa97d011df (diff) |
Only log debug messages if debug logging is enabled
Diffstat (limited to 'src/util/db')
-rw-r--r-- | src/util/db/dbconnection.cpp | 16 | ||||
-rw-r--r-- | src/util/db/dbconnectionpooled.cpp | 8 | ||||
-rw-r--r-- | src/util/db/sqltransaction.cpp | 24 |
3 files changed, 30 insertions, 18 deletions
diff --git a/src/util/db/dbconnection.cpp b/src/util/db/dbconnection.cpp index 98a43d6b42..ee78dfec0f 100644 --- a/src/util/db/dbconnection.cpp +++ b/src/util/db/dbconnection.cpp @@ -313,9 +313,11 @@ DbConnection::~DbConnection() { } bool DbConnection::open() { - kLogger.debug() - << "Opening database connection" - << *this; + if (kLogger.debugEnabled()) { + kLogger.debug() + << "Opening database connection" + << *this; + } if (!m_sqlDatabase.open()) { kLogger.warning() << "Failed to open database connection" @@ -343,9 +345,11 @@ void DbConnection::close() { << "Rolled back open transaction before closing database connection:" << *this; } - kLogger.debug() - << "Closing database connection:" - << *this; + if (kLogger.debugEnabled()) { + kLogger.debug() + << "Closing database connection:" + << *this; + } m_sqlDatabase.close(); } } diff --git a/src/util/db/dbconnectionpooled.cpp b/src/util/db/dbconnectionpooled.cpp index cf74c4d2d5..33369511eb 100644 --- a/src/util/db/dbconnectionpooled.cpp +++ b/src/util/db/dbconnectionpooled.cpp @@ -26,9 +26,11 @@ DbConnectionPooled::operator QSqlDatabase() const { << "Thread-local database connection not found"; return QSqlDatabase(); // abort } - kLogger.debug() - << "Found thread-local database connection" - << *pDbConnection;; + if (kLogger.debugEnabled()) { + kLogger.debug() + << "Found thread-local database connection" + << *pDbConnection;; + } return *pDbConnection; } diff --git a/src/util/db/sqltransaction.cpp b/src/util/db/sqltransaction.cpp index 463637743c..c6ae4fe108 100644 --- a/src/util/db/sqltransaction.cpp +++ b/src/util/db/sqltransaction.cpp @@ -18,9 +18,11 @@ bool beginTransaction(QSqlDatabase database) { return false; } if (database.transaction()) { - kLogger.debug() - << "Started new SQL database transaction on" - << database.connectionName(); + if (kLogger.debugEnabled()) { + kLogger.debug() + << "Started new SQL database transaction on" + << database.connectionName(); + } return true; } else { kLogger.warning() @@ -63,9 +65,11 @@ bool SqlTransaction::commit() { return false; } if (m_database.commit()) { - kLogger.debug() - << "Committed SQL database transaction on" - << m_database.connectionName(); + if (kLogger.debugEnabled()) { + kLogger.debug() + << "Committed SQL database transaction on" + << m_database.connectionName(); + } release(); // commit/rollback only once return true; } else { @@ -84,9 +88,11 @@ bool SqlTransaction::rollback() { return false; } if (m_database.rollback()) { - kLogger.debug() - << "Rolled back SQL database transaction on" - << m_database.connectionName(); + if (kLogger.debugEnabled()) { + kLogger.debug() + << "Rolled back SQL database transaction on" + << m_database.connectionName(); + } release(); // commit/rollback only once return true; } else { |