diff --git a/ElunaUtility.h b/ElunaUtility.h index 71b54fb2ea..cd95786095 100644 --- a/ElunaUtility.h +++ b/ElunaUtility.h @@ -22,6 +22,7 @@ #ifdef TRINITY #include "QueryResult.h" #include "Log.h" +#include "fmt/printf.h" #ifdef CATA #include "Object.h" #endif @@ -49,9 +50,16 @@ typedef QueryResult ElunaQuery; #endif #ifdef TRINITY -#define ELUNA_LOG_INFO(...) TC_LOG_INFO("eluna", __VA_ARGS__); -#define ELUNA_LOG_ERROR(...) TC_LOG_ERROR("eluna", __VA_ARGS__); -#define ELUNA_LOG_DEBUG(...) TC_LOG_DEBUG("eluna", __VA_ARGS__); +#define ELUNA_LOG_TC_FMT(TC_LOG_MACRO, ...) \ + try { \ + std::string message = fmt::sprintf(__VA_ARGS__); \ + TC_LOG_MACRO("eluna", "{}", message); \ + } catch (const std::exception& e) { \ + TC_LOG_MACRO("eluna", "Failed to format log message: {}", e.what()); \ + } +#define ELUNA_LOG_INFO(...) ELUNA_LOG_TC_FMT(TC_LOG_INFO, __VA_ARGS__); +#define ELUNA_LOG_ERROR(...) ELUNA_LOG_TC_FMT(TC_LOG_ERROR, __VA_ARGS__); +#define ELUNA_LOG_DEBUG(...) ELUNA_LOG_TC_FMT(TC_LOG_DEBUG, __VA_ARGS__); #elif defined(AZEROTHCORE) #define ELUNA_LOG_INFO(...) LOG_INFO("eluna", __VA_ARGS__); #define ELUNA_LOG_ERROR(...) LOG_ERROR("eluna", __VA_ARGS__); diff --git a/TrinityCore/PlayerMethods.h b/TrinityCore/PlayerMethods.h index f952bf999c..4148f1da4a 100644 --- a/TrinityCore/PlayerMethods.h +++ b/TrinityCore/PlayerMethods.h @@ -2092,9 +2092,7 @@ namespace LuaPlayer time_t muteTime = time(NULL) + muteseconds; player->GetSession()->m_muteTime = muteTime; - std::ostringstream oss; - oss << "UPDATE account SET mutetime = " << muteTime << " WHERE id = " << player->GetSession()->GetAccountId(); - LoginDatabase.PExecute("%s", oss.str().c_str()); + LoginDatabase.PExecute("UPDATE account SET mutetime = {} WHERE id = {}", muteTime, player->GetSession()->GetAccountId()); return 0; }