mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/Logging: Performance-related tweaks to logging system
All sLog->out* functions (except outCommand atm) are replaced with TC_LOG_* macros.
Memleak fix
This commit is contained in:
@@ -69,7 +69,7 @@ public:
|
||||
/// Print out the usage string for this program on the console.
|
||||
void usage(const char *prog)
|
||||
{
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "Usage: \n %s [<options>]\n"
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "Usage: \n %s [<options>]\n"
|
||||
" -c config_file use config_file as configuration file\n\r",
|
||||
prog);
|
||||
}
|
||||
@@ -103,11 +103,11 @@ extern int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "%s (authserver)", _FULLVERSION);
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "<Ctrl-C> to stop.\n");
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "Using configuration file %s.", cfg_file);
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "%s (authserver)", _FULLVERSION);
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "<Ctrl-C> to stop.\n");
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "Using configuration file %s.", cfg_file);
|
||||
|
||||
sLog->outWarn(LOG_FILTER_AUTHSERVER, "%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
TC_LOG_WARN(LOG_FILTER_AUTHSERVER, "%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
|
||||
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
|
||||
ACE_Reactor::instance(new ACE_Reactor(new ACE_Dev_Poll_Reactor(ACE::max_handles(), 1), 1), true);
|
||||
@@ -115,7 +115,7 @@ extern int main(int argc, char **argv)
|
||||
ACE_Reactor::instance(new ACE_Reactor(new ACE_TP_Reactor(), true), true);
|
||||
#endif
|
||||
|
||||
sLog->outDebug(LOG_FILTER_AUTHSERVER, "Max allowed open files is %d", ACE::max_handles());
|
||||
TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Max allowed open files is %d", ACE::max_handles());
|
||||
|
||||
// authserver PID file creation
|
||||
std::string pidfile = ConfigMgr::GetStringDefault("PidFile", "");
|
||||
@@ -124,10 +124,10 @@ extern int main(int argc, char **argv)
|
||||
uint32 pid = CreatePIDFile(pidfile);
|
||||
if (!pid)
|
||||
{
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Cannot create PID file %s.\n", pidfile.c_str());
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Cannot create PID file %s.\n", pidfile.c_str());
|
||||
return 1;
|
||||
}
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "Daemon PID: %u\n", pid);
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "Daemon PID: %u\n", pid);
|
||||
}
|
||||
|
||||
// Initialize the database connection
|
||||
@@ -138,7 +138,7 @@ extern int main(int argc, char **argv)
|
||||
sRealmList->Initialize(ConfigMgr::GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||
if (sRealmList->size() == 0)
|
||||
{
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "No valid realms specified.");
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "No valid realms specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ extern int main(int argc, char **argv)
|
||||
int32 rmport = ConfigMgr::GetIntDefault("RealmServerPort", 3724);
|
||||
if (rmport < 0 || rmport > 0xFFFF)
|
||||
{
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Specified port out of allowed range (1-65535)");
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Specified port out of allowed range (1-65535)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ extern int main(int argc, char **argv)
|
||||
|
||||
if (acceptor.open(bind_addr, ACE_Reactor::instance(), ACE_NONBLOCK) == -1)
|
||||
{
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Auth server can not bind to %s:%d", bind_ip.c_str(), rmport);
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Auth server can not bind to %s:%d", bind_ip.c_str(), rmport);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -186,11 +186,11 @@ extern int main(int argc, char **argv)
|
||||
ULONG_PTR curAff = Aff & appAff; // remove non accessible processors
|
||||
|
||||
if (!curAff)
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Processors marked in UseProcessors bitmask (hex) %x not accessible for authserver. Accessible processors bitmask (hex): %x", Aff, appAff);
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Processors marked in UseProcessors bitmask (hex) %x not accessible for authserver. Accessible processors bitmask (hex): %x", Aff, appAff);
|
||||
else if (SetProcessAffinityMask(hProcess, curAff))
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "Using processors (bitmask, hex): %x", curAff);
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "Using processors (bitmask, hex): %x", curAff);
|
||||
else
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Can't set used processors (hex): %x", curAff);
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Can't set used processors (hex): %x", curAff);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -200,9 +200,9 @@ extern int main(int argc, char **argv)
|
||||
if (Prio)
|
||||
{
|
||||
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "The auth server process priority class has been set to HIGH");
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "The auth server process priority class has been set to HIGH");
|
||||
else
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Can't set auth server process priority class.");
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Can't set auth server process priority class.");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -224,7 +224,7 @@ extern int main(int argc, char **argv)
|
||||
if ((++loopCounter) == numLoops)
|
||||
{
|
||||
loopCounter = 0;
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "Ping MySQL to keep connection alive");
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "Ping MySQL to keep connection alive");
|
||||
LoginDatabase.KeepAlive();
|
||||
}
|
||||
}
|
||||
@@ -232,7 +232,7 @@ extern int main(int argc, char **argv)
|
||||
// Close the Database Pool and library
|
||||
StopDB();
|
||||
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "Halting process...");
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "Halting process...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -244,32 +244,32 @@ bool StartDB()
|
||||
std::string dbstring = ConfigMgr::GetStringDefault("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Database not specified");
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Database not specified");
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 worker_threads = ConfigMgr::GetIntDefault("LoginDatabase.WorkerThreads", 1);
|
||||
if (worker_threads < 1 || worker_threads > 32)
|
||||
{
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Improper value specified for LoginDatabase.WorkerThreads, defaulting to 1.");
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Improper value specified for LoginDatabase.WorkerThreads, defaulting to 1.");
|
||||
worker_threads = 1;
|
||||
}
|
||||
|
||||
int32 synch_threads = ConfigMgr::GetIntDefault("LoginDatabase.SynchThreads", 1);
|
||||
if (synch_threads < 1 || synch_threads > 32)
|
||||
{
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Improper value specified for LoginDatabase.SynchThreads, defaulting to 1.");
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Improper value specified for LoginDatabase.SynchThreads, defaulting to 1.");
|
||||
synch_threads = 1;
|
||||
}
|
||||
|
||||
// NOTE: While authserver is singlethreaded you should keep synch_threads == 1. Increasing it is just silly since only 1 will be used ever.
|
||||
if (!LoginDatabase.Open(dbstring.c_str(), uint8(worker_threads), uint8(synch_threads)))
|
||||
{
|
||||
sLog->outError(LOG_FILTER_AUTHSERVER, "Cannot connect to database");
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Cannot connect to database");
|
||||
return false;
|
||||
}
|
||||
|
||||
sLog->outInfo(LOG_FILTER_AUTHSERVER, "Started auth database connection pool.");
|
||||
TC_LOG_INFO(LOG_FILTER_AUTHSERVER, "Started auth database connection pool.");
|
||||
sLog->SetRealmId(0); // Enables DB appenders when realm is set.
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user