Added a param to show the underlying db queries

This commit is contained in:
emeric
2023-11-17 08:36:20 +01:00
parent d7451e5393
commit 60bb6170e2
2 changed files with 6 additions and 1 deletions
+2
View File
@@ -12,6 +12,8 @@ log-file = "";
access-log-file = ""; access-log-file = "";
# Logger configuration, see log-config in https://webtoolkit.eu/wt/doc/reference/html/overview.html#config_general # Logger configuration, see log-config in https://webtoolkit.eu/wt/doc/reference/html/overview.html#config_general
log-config = "* -debug -info:WebRequest"; log-config = "* -debug -info:WebRequest";
# Output db queries on stdout
db-show-queries = false;
# Listen port/addr of the web server # Listen port/addr of the web server
listen-port = 5082; listen-port = 5082;
+4 -1
View File
@@ -24,6 +24,8 @@
#include "services/database/Session.hpp" #include "services/database/Session.hpp"
#include "services/database/User.hpp" #include "services/database/User.hpp"
#include "utils/IConfig.hpp"
#include "utils/Service.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
namespace Database namespace Database
@@ -87,7 +89,8 @@ namespace Database
LMS_LOG(DB, INFO) << "Creating connection pool on file " << dbPath.string(); LMS_LOG(DB, INFO) << "Creating connection pool on file " << dbPath.string();
auto connection{ std::make_unique<Connection>(dbPath.string()) }; auto connection{ std::make_unique<Connection>(dbPath.string()) };
// connection->setProperty("show-queries", "true"); if (Service<IConfig>::get()->getBool("db-show-queries", false))
connection->setProperty("show-queries", "true");
auto connectionPool{ std::make_unique<Wt::Dbo::FixedSqlConnectionPool>(std::move(connection), connectionCount) }; auto connectionPool{ std::make_unique<Wt::Dbo::FixedSqlConnectionPool>(std::move(connection), connectionCount) };
connectionPool->setTimeout(std::chrono::seconds{ 10 }); connectionPool->setTimeout(std::chrono::seconds{ 10 });