Skip to content

Commit

Permalink
db: Add enableTimers()
Browse files Browse the repository at this point in the history
  • Loading branch information
zach2good committed Jan 30, 2025
1 parent 7a1c338 commit 9bb1f38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/common/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace
"Connection refused",
"Can't connect to server",
};

bool timersEnabled = false;
} // namespace

auto db::getConnection() -> std::unique_ptr<sql::Connection>
Expand Down Expand Up @@ -127,7 +129,7 @@ auto db::detail::timer(std::string const& query) -> xi::final_action<std::functi
{
const auto end = hires_clock::now();
const auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
if (settings::get<bool>("logging.SQL_SLOW_QUERY_LOG_ENABLE"))
if (timersEnabled && settings::get<bool>("logging.SQL_SLOW_QUERY_LOG_ENABLE"))
{
if (duration > settings::get<uint32>("logging.SQL_SLOW_QUERY_ERROR_TIME"))
{
Expand Down Expand Up @@ -389,3 +391,8 @@ bool db::transactionRollback()

return true;
}

void db::enableTimers()
{
timersEnabled = true;
}
2 changes: 2 additions & 0 deletions src/common/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,4 +721,6 @@ namespace db
bool transactionStart();
bool transactionCommit();
bool transactionRollback();

void enableTimers();
} // namespace db
2 changes: 1 addition & 1 deletion src/map/ai/helpers/gambits_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ int32 do_init(int32 argc, char** argv)

moduleutils::ReportLuaModuleUsage();

db::enableTimers();

ShowInfo("The map-server is ready to work!");
ShowInfo("=======================================================================");

Expand Down

0 comments on commit 9bb1f38

Please sign in to comment.