diff options
author | Yehonal <yehonal.azeroth@gmail.com> | 2016-09-22 16:22:42 +0200 |
---|---|---|
committer | Yehonal <yehonal.azeroth@gmail.com> | 2016-09-24 14:45:57 +0200 |
commit | 0eca04f18bcdb1d2a4f41b0a6566669d512a9175 (patch) | |
tree | 409c597c4df94d37a251528820f953c9b09fb303 /src | |
parent | c49be4c5300a38c4f46a34342507ada715ca886a (diff) |
Core/Logging Fixed db logging clean timer
Diffstat (limited to 'src')
-rw-r--r-- | src/game/World/World.cpp | 17 | ||||
-rw-r--r-- | src/game/World/World.h | 1 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp index 4650aec6a8..269f9786d5 100644 --- a/src/game/World/World.cpp +++ b/src/game/World/World.cpp @@ -920,6 +920,9 @@ void World::LoadConfigSettings(bool reload) m_timers[WUPDATE_CLEANDB].SetInterval(m_int_configs[CONFIG_LOGDB_CLEARINTERVAL] * MINUTE * IN_MILLISECONDS); m_timers[WUPDATE_CLEANDB].Reset(); } + m_int_configs[CONFIG_LOGDB_CLEARTIME] = sConfigMgr->GetIntDefault("LogDB.Opt.ClearTime", 1209600); // 14 days default + sLog->outString("Will clear `logs` table of entries older than %i seconds every %u minutes.", + m_int_configs[CONFIG_LOGDB_CLEARTIME], m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]); m_int_configs[CONFIG_TELEPORT_TIMEOUT_NEAR] = sConfigMgr->GetIntDefault("TeleportTimeoutNear", 25); // pussywizard m_int_configs[CONFIG_TELEPORT_TIMEOUT_FAR] = sConfigMgr->GetIntDefault("TeleportTimeoutFar", 45); // pussywizard @@ -2022,16 +2025,18 @@ void World::Update(uint32 diff) } /// <li> Clean logs table - if(getIntConfig(CONFIG_LOGDB_CLEARINTERVAL) > 0) // if not enabled, ignore the timer + if (sWorld->getIntConfig(CONFIG_LOGDB_CLEARTIME) > 0) // if not enabled, ignore the timer { if (m_timers[WUPDATE_CLEANDB].Passed()) { - uint32 tmpDiff = (m_gameTime - m_startTime); - uint32 maxClientsNum = GetMaxActiveSessionCount(); - m_timers[WUPDATE_CLEANDB].Reset(); - LoginDatabase.PExecute("DELETE FROM logs WHERE (time + %u) < " UI64FMTD ";", - getIntConfig(CONFIG_LOGDB_CLEARINTERVAL), uint64(time(0))); + + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_OLD_LOGS); + + stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_LOGDB_CLEARTIME)); + stmt->setUInt32(1, uint32(time(0))); + + LoginDatabase.Execute(stmt); } } diff --git a/src/game/World/World.h b/src/game/World/World.h index a12a64f491..ddb2e16733 100644 --- a/src/game/World/World.h +++ b/src/game/World/World.h @@ -288,6 +288,7 @@ enum WorldIntConfigs CONFIG_PLAYER_ALLOW_COMMANDS, CONFIG_NUMTHREADS, CONFIG_LOGDB_CLEARINTERVAL, + CONFIG_LOGDB_CLEARTIME, CONFIG_TELEPORT_TIMEOUT_NEAR, // pussywizard CONFIG_TELEPORT_TIMEOUT_FAR, // pussywizard CONFIG_MAX_ALLOWED_MMR_DROP, // pussywizard |