mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 18:40:28 +00:00
feat(Core/Logging): rework logging (#4692)
* feat(Core/Logging): rework logging * correct level for sql.sql * del unused config options * Correct build * correct after merge * whitespace 20:29:37 1. 'Player.cpp'. Replace (1) 20:29:37 2. 'ObjectMgr.cpp'. Replace (3) * 1 * correct logging * correct affter merge * 1 * 2 * LOG_LEVEL_WARN * #include "AppenderDB.h" * 3 * 4 * 5 * 1. 'WorldSocket.cpp'. Replace (1) * 6 * 1
This commit is contained in:
@@ -48,22 +48,18 @@ void HandleSignal(int sigNum)
|
||||
{
|
||||
switch (sigNum)
|
||||
{
|
||||
case SIGINT:
|
||||
World::StopNow(RESTART_EXIT_CODE);
|
||||
break;
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
World::StopNow(RESTART_EXIT_CODE);
|
||||
break;
|
||||
case SIGTERM:
|
||||
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
|
||||
case SIGBREAK:
|
||||
if (m_ServiceStatus != 1)
|
||||
case SIGBREAK:
|
||||
if (m_ServiceStatus != 1)
|
||||
#endif
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
break;
|
||||
/*case SIGSEGV:
|
||||
sLog->outString("ZOMG! SIGSEGV handled!");
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
break;*/
|
||||
default:
|
||||
break;
|
||||
World::StopNow(SHUTDOWN_EXIT_CODE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +78,7 @@ public:
|
||||
if (!_delayTime)
|
||||
return;
|
||||
|
||||
sLog->outString("Starting up anti-freeze thread (%u seconds max stuck time)...", _delayTime / 1000);
|
||||
LOG_INFO("server", "Starting up anti-freeze thread (%u seconds max stuck time)...", _delayTime / 1000);
|
||||
while (!World::IsStopped())
|
||||
{
|
||||
uint32 curtime = getMSTime();
|
||||
@@ -93,13 +89,13 @@ public:
|
||||
}
|
||||
else if (getMSTimeDiff(_lastChange, curtime) > _delayTime)
|
||||
{
|
||||
sLog->outString("World Thread hangs, kicking out server!");
|
||||
LOG_INFO("server", "World Thread hangs, kicking out server!");
|
||||
ABORT();
|
||||
}
|
||||
|
||||
acore::Thread::Sleep(1000);
|
||||
}
|
||||
sLog->outString("Anti-freeze thread exiting without problems.");
|
||||
LOG_INFO("server", "Anti-freeze thread exiting without problems.");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -116,33 +112,33 @@ int Master::Run()
|
||||
BigNumber seed1;
|
||||
seed1.SetRand(16 * 8);
|
||||
|
||||
sLog->outString("%s (worldserver-daemon)", GitRevision::GetFullVersion());
|
||||
sLog->outString("<Ctrl-C> to stop.\n");
|
||||
LOG_INFO("server", "%s (worldserver-daemon)", GitRevision::GetFullVersion());
|
||||
LOG_INFO("server", "<Ctrl-C> to stop.\n");
|
||||
|
||||
sLog->outString(" █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗");
|
||||
sLog->outString(" ██╔══██╗╚══███╔╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝██║ ██║");
|
||||
sLog->outString(" ███████║ ███╔╝ █████╗ ██████╔╝██║ ██║ ██║ ███████║");
|
||||
sLog->outString(" ██╔══██║ ███╔╝ ██╔══╝ ██╔══██╗██║ ██║ ██║ ██╔══██║");
|
||||
sLog->outString(" ██║ ██║███████╗███████╗██║ ██║╚██████╔╝ ██║ ██║ ██║");
|
||||
sLog->outString(" ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝");
|
||||
sLog->outString(" ██████╗ ██████╗ ██████╗ ███████╗");
|
||||
sLog->outString(" ██╔════╝██╔═══██╗██╔══██╗██╔═══╝");
|
||||
sLog->outString(" ██║ ██║ ██║██████╔╝█████╗");
|
||||
sLog->outString(" ██║ ██║ ██║██╔══██╗██╔══╝");
|
||||
sLog->outString(" ╚██████╗╚██████╔╝██║ ██║███████╗");
|
||||
sLog->outString(" ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝\n");
|
||||
LOG_INFO("server", " █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗");
|
||||
LOG_INFO("server", " ██╔══██╗╚══███╔╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝██║ ██║");
|
||||
LOG_INFO("server", " ███████║ ███╔╝ █████╗ ██████╔╝██║ ██║ ██║ ███████║");
|
||||
LOG_INFO("server", " ██╔══██║ ███╔╝ ██╔══╝ ██╔══██╗██║ ██║ ██║ ██╔══██║");
|
||||
LOG_INFO("server", " ██║ ██║███████╗███████╗██║ ██║╚██████╔╝ ██║ ██║ ██║");
|
||||
LOG_INFO("server", " ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝");
|
||||
LOG_INFO("server", " ██████╗ ██████╗ ██████╗ ███████╗");
|
||||
LOG_INFO("server", " ██╔════╝██╔═══██╗██╔══██╗██╔═══╝");
|
||||
LOG_INFO("server", " ██║ ██║ ██║██████╔╝█████╗");
|
||||
LOG_INFO("server", " ██║ ██║ ██║██╔══██╗██╔══╝");
|
||||
LOG_INFO("server", " ╚██████╗╚██████╔╝██║ ██║███████╗");
|
||||
LOG_INFO("server", " ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝\n");
|
||||
|
||||
sLog->outString(" AzerothCore 3.3.5a - www.azerothcore.org\n");
|
||||
LOG_INFO("server", " AzerothCore 3.3.5a - www.azerothcore.org\n");
|
||||
|
||||
/// worldserver PID file creation
|
||||
std::string pidFile = sConfigMgr->GetOption<std::string>("PidFile", "");
|
||||
if (!pidFile.empty())
|
||||
{
|
||||
if (uint32 pid = CreatePIDFile(pidFile))
|
||||
sLog->outError("Daemon PID: %u\n", pid); // outError for red color in console
|
||||
LOG_ERROR("server", "Daemon PID: %u\n", pid); // outError for red color in console
|
||||
else
|
||||
{
|
||||
sLog->outError("Cannot create PID file %s (possible error: permission)\n", pidFile.c_str());
|
||||
LOG_ERROR("server", "Cannot create PID file %s (possible error: permission)\n", pidFile.c_str());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -214,20 +210,20 @@ int Master::Run()
|
||||
ULONG_PTR currentAffinity = affinity & appAff; // remove non accessible processors
|
||||
|
||||
if (!currentAffinity)
|
||||
sLog->outError("Processors marked in UseProcessors bitmask (hex) %x are not accessible for the worldserver. Accessible processors bitmask (hex): %x", affinity, appAff);
|
||||
LOG_ERROR("server", "Processors marked in UseProcessors bitmask (hex) %x are not accessible for the worldserver. Accessible processors bitmask (hex): %x", affinity, appAff);
|
||||
else if (SetProcessAffinityMask(hProcess, currentAffinity))
|
||||
sLog->outString("Using processors (bitmask, hex): %x", currentAffinity);
|
||||
LOG_INFO("server", "Using processors (bitmask, hex): %x", currentAffinity);
|
||||
else
|
||||
sLog->outError("Can't set used processors (hex): %x", currentAffinity);
|
||||
LOG_ERROR("server", "Can't set used processors (hex): %x", currentAffinity);
|
||||
}
|
||||
}
|
||||
|
||||
if (highPriority)
|
||||
{
|
||||
if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
|
||||
sLog->outString("worldserver process priority class set to HIGH");
|
||||
LOG_INFO("server", "worldserver process priority class set to HIGH");
|
||||
else
|
||||
sLog->outError("Can't set worldserver process priority class.");
|
||||
LOG_ERROR("server", "Can't set worldserver process priority class.");
|
||||
}
|
||||
|
||||
#else // Linux
|
||||
@@ -242,21 +238,21 @@ int Master::Run()
|
||||
CPU_SET(i, &mask);
|
||||
|
||||
if (sched_setaffinity(0, sizeof(mask), &mask))
|
||||
sLog->outError("Can't set used processors (hex): %x, error: %s", affinity, strerror(errno));
|
||||
LOG_ERROR("server", "Can't set used processors (hex): %x, error: %s", affinity, strerror(errno));
|
||||
else
|
||||
{
|
||||
CPU_ZERO(&mask);
|
||||
sched_getaffinity(0, sizeof(mask), &mask);
|
||||
sLog->outString("Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
|
||||
LOG_INFO("server", "Using processors (bitmask, hex): %lx", *(__cpu_mask*)(&mask));
|
||||
}
|
||||
}
|
||||
|
||||
if (highPriority)
|
||||
{
|
||||
if (setpriority(PRIO_PROCESS, 0, PROCESS_HIGH_PRIORITY))
|
||||
sLog->outError("Can't set worldserver process priority class, error: %s", strerror(errno));
|
||||
LOG_ERROR("server", "Can't set worldserver process priority class, error: %s", strerror(errno));
|
||||
else
|
||||
sLog->outString("worldserver process priority class set to %i", getpriority(PRIO_PROCESS, 0));
|
||||
LOG_INFO("server", "worldserver process priority class set to %i", getpriority(PRIO_PROCESS, 0));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -285,7 +281,7 @@ int Master::Run()
|
||||
std::string bindIp = sConfigMgr->GetOption<std::string>("BindIP", "0.0.0.0");
|
||||
if (sWorldSocketMgr->StartNetwork(worldPort, bindIp.c_str()) == -1)
|
||||
{
|
||||
sLog->outError("Failed to start network");
|
||||
LOG_ERROR("server", "Failed to start network");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
// go down and shutdown the server
|
||||
}
|
||||
@@ -293,7 +289,7 @@ int Master::Run()
|
||||
// set server online (allow connecting now)
|
||||
LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_INVALID, realmID);
|
||||
|
||||
sLog->outString("%s (worldserver-daemon) ready...", GitRevision::GetFullVersion());
|
||||
LOG_INFO("server", "%s (worldserver-daemon) ready...", GitRevision::GetFullVersion());
|
||||
|
||||
// when the main thread closes the singletons get unloaded
|
||||
// since worldrunnable uses them, it will crash if unloaded after master
|
||||
@@ -322,7 +318,7 @@ int Master::Run()
|
||||
|
||||
_StopDB();
|
||||
|
||||
sLog->outString("Halting process...");
|
||||
LOG_INFO("server", "Halting process...");
|
||||
|
||||
if (cliThread)
|
||||
{
|
||||
@@ -388,8 +384,6 @@ bool Master::_StartDB()
|
||||
{
|
||||
MySQL::Library_Init();
|
||||
|
||||
sLog->SetLogDB(false);
|
||||
|
||||
// Load databases
|
||||
DatabaseLoader loader;
|
||||
loader
|
||||
@@ -404,7 +398,7 @@ bool Master::_StartDB()
|
||||
realmID = sConfigMgr->GetOption<int32>("RealmID", 0);
|
||||
if (!realmID)
|
||||
{
|
||||
sLog->outError("Realm ID not defined in configuration file");
|
||||
LOG_ERROR("server", "Realm ID not defined in configuration file");
|
||||
return false;
|
||||
}
|
||||
else if (realmID > 255)
|
||||
@@ -414,13 +408,11 @@ bool Master::_StartDB()
|
||||
* with a size of uint8 we can "only" store up to 255 realms
|
||||
* anything further the client will behave anormaly
|
||||
*/
|
||||
sLog->outError("Realm ID must range from 1 to 255");
|
||||
LOG_ERROR("server", "Realm ID must range from 1 to 255");
|
||||
return false;
|
||||
}
|
||||
sLog->outString("Realm running as realm ID %d", realmID);
|
||||
|
||||
///- Initialize the DB logging system
|
||||
sLog->SetRealmID(realmID);
|
||||
LOG_INFO("server", "Realm running as realm ID %d", realmID);
|
||||
|
||||
///- Clean the database before starting
|
||||
ClearOnlineAccounts();
|
||||
@@ -430,7 +422,7 @@ bool Master::_StartDB()
|
||||
|
||||
sWorld->LoadDBVersion();
|
||||
|
||||
sLog->outString("Using World DB: %s", sWorld->GetDBVersion());
|
||||
LOG_INFO("server", "Using World DB: %s", sWorld->GetDBVersion());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user