mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
Core/Logging Fixed db logging clean timer
This commit is contained in:
@@ -55,6 +55,7 @@ void LoginDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(LOGIN_UPD_MUTE_TIME_LOGIN, "UPDATE account SET mutetime = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_UPD_LAST_IP, "UPDATE account SET last_ip = ? WHERE username = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_UPD_ACCOUNT_ONLINE, "UPDATE account SET online = online | (1<<(?-1)) WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_DEL_OLD_LOGS, "DELETE FROM logs WHERE (time + ?) < ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_DEL_ACCOUNT_ACCESS, "DELETE FROM account_access WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM, "DELETE FROM account_access WHERE id = ? AND (RealmID = ? OR RealmID = -1)", CONNECTION_ASYNC);
|
||||
PrepareStatement(LOGIN_INS_ACCOUNT_ACCESS, "INSERT INTO account_access (id,gmlevel,RealmID) VALUES (?, ?, ?)", CONNECTION_ASYNC);
|
||||
|
||||
@@ -75,6 +75,7 @@ enum LoginDatabaseStatements
|
||||
LOGIN_UPD_MUTE_TIME_LOGIN,
|
||||
LOGIN_UPD_LAST_IP,
|
||||
LOGIN_UPD_ACCOUNT_ONLINE,
|
||||
LOGIN_DEL_OLD_LOGS,
|
||||
LOGIN_DEL_ACCOUNT_ACCESS,
|
||||
LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM,
|
||||
LOGIN_INS_ACCOUNT_ACCESS,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user