From 9bb1f3881a49642341f54fd13d19aafc59abe992 Mon Sep 17 00:00:00 2001 From: Zach Toogood Date: Thu, 30 Jan 2025 21:45:18 +0000 Subject: [PATCH] db: Add enableTimers() --- src/common/database.cpp | 9 ++++++++- src/common/database.h | 2 ++ src/map/ai/helpers/gambits_container.cpp | 2 +- src/map/map.cpp | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/common/database.cpp b/src/common/database.cpp index 5bd15fc2cd2..c2f7c63154d 100644 --- a/src/common/database.cpp +++ b/src/common/database.cpp @@ -51,6 +51,8 @@ namespace "Connection refused", "Can't connect to server", }; + + bool timersEnabled = false; } // namespace auto db::getConnection() -> std::unique_ptr @@ -127,7 +129,7 @@ auto db::detail::timer(std::string const& query) -> xi::final_action(end - start).count(); - if (settings::get("logging.SQL_SLOW_QUERY_LOG_ENABLE")) + if (timersEnabled && settings::get("logging.SQL_SLOW_QUERY_LOG_ENABLE")) { if (duration > settings::get("logging.SQL_SLOW_QUERY_ERROR_TIME")) { @@ -389,3 +391,8 @@ bool db::transactionRollback() return true; } + +void db::enableTimers() +{ + timersEnabled = true; +} diff --git a/src/common/database.h b/src/common/database.h index 90023d146cb..5869a03479c 100644 --- a/src/common/database.h +++ b/src/common/database.h @@ -721,4 +721,6 @@ namespace db bool transactionStart(); bool transactionCommit(); bool transactionRollback(); + + void enableTimers(); } // namespace db diff --git a/src/map/ai/helpers/gambits_container.cpp b/src/map/ai/helpers/gambits_container.cpp index e9513ab8774..5edca437e5f 100644 --- a/src/map/ai/helpers/gambits_container.cpp +++ b/src/map/ai/helpers/gambits_container.cpp @@ -23,7 +23,7 @@ namespace gambits // Return a new unique identifier for a gambit auto CGambitsContainer::NewGambitIdentifier(Gambit_t const& gambit) const -> std::string { - return std::format("{}_{}_{}", gambits.size(), gambit.predicate_groups.size(), gambit.actions.size()); + return fmt::format("{}_{}_{}", gambits.size(), gambit.predicate_groups.size(), gambit.actions.size()); } // Validate gambit before it's inserted into the gambit list diff --git a/src/map/map.cpp b/src/map/map.cpp index c11e30d5df1..b0b324a4b70 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -349,6 +349,8 @@ int32 do_init(int32 argc, char** argv) moduleutils::ReportLuaModuleUsage(); + db::enableTimers(); + ShowInfo("The map-server is ready to work!"); ShowInfo("=======================================================================");