From e9f7df9a2c837654b1aafd84c1331bc1645efefe Mon Sep 17 00:00:00 2001 From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch> Date: Thu, 6 May 2021 17:13:16 +0200 Subject: [PATCH] Add more logLevel conditional to silence log msgs for production --- .../GeoModelDBManager/GeoModelDBManager/GMDBManager.h | 1 + GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h b/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h index b5741ee4c..2f0ababa0 100644 --- a/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h +++ b/GeoModelIO/GeoModelDBManager/GeoModelDBManager/GMDBManager.h @@ -45,6 +45,7 @@ public: bool initDB(); + /// level --> 0: silenced/production - 1: info - 2: verbose - 3: debug void setLogLevel(const unsigned int level) {m_logLevel = level;} int loadGeoNodeTypesAndBuildCache(); diff --git a/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp b/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp index c4d861463..6d2368710 100644 --- a/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp +++ b/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp @@ -96,7 +96,7 @@ GMDBManager::GMDBManager(const std::string &path) : m_dbpath(path), m_dbIsOK(fal } // set default logLevel - m_logLevel = 0; + m_logLevel = 1; // 0: silenced/production - 1: info - 2: verbose - 3: debug m_dbIsOK = false; @@ -106,10 +106,11 @@ GMDBManager::GMDBManager(const std::string &path) : m_dbpath(path), m_dbIsOK(fal // Test if there was an error if (exit == SQLITE_OK) { - std::cout << "The Geometry Database '"<< path << "' has been opened successfully!" << std::endl; + if ( m_logLevel >= 1 ) + std::cout << "The Geometry Database '"<< path << "' has been opened successfully!" << std::endl; m_dbIsOK = true; } else { - std::cout << "DB Open Error: " << sqlite3_errmsg(m_d->m_dbSqlite) << std::endl; + std::cerr << "DB Open Error: " << sqlite3_errmsg(m_d->m_dbSqlite) << std::endl; m_dbIsOK = false; } @@ -420,7 +421,7 @@ bool GMDBManager::addListOfRecordsToTable(const std::string tableName, const std if(m_debug) std::cout << "tableColString:" << tableColString << std::endl; unsigned int nRecords = records.size(); - if (m_logLevel > 0) { + if (m_logLevel >= 2) { std::cout << "Info: number of " << tableName << " records to dump into the DB:" << nRecords << std::endl; } // preparing the SQL query @@ -458,7 +459,7 @@ bool GMDBManager::addListOfRecordsToTable(const std::string tableName, const std if(m_debug) std::cout << "tableColString:" << tableColString << std::endl; unsigned int nRecords = records.size(); - if (m_logLevel > 0) { + if (m_logLevel >= 2) { std::cout << "Info: number of " << tableName << " records to dump into the DB:" << nRecords << std::endl; } -- GitLab