feat: logging structure improvements (#2037)

* feat: logging structure improvements

tested that logs are sorted by the folder argument and that the directories are created recursively.
tested that crash dumps follow the same exact name (+Crash_...name..._pid.log) so you can match the crash dump to the corresponding log file much easier

* Potential fix for pull request finding 'Use parsed cloneID when constructing the log folder'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* const

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
David Markowitz
2026-09-26 19:35:58 -07:00
committed by GitHub
parent 129199e452
commit 6f3a8d502f
7 changed files with 47 additions and 22 deletions

View File

@@ -99,6 +99,10 @@ namespace Game {
std::string projectVersion = PROJECT_VERSION;
} // namespace Game
namespace {
std::string g_ServiceName;
}
namespace {
struct TempSessionInfo {
SystemAddress sysAddr;
@@ -125,7 +129,10 @@ void HandleMasterPacket(Packet* packet);
void HandlePacket(Packet* packet);
int main(int argc, char** argv) {
Diagnostics::SetProcessName("World");
const auto curTimeStr = std::to_string(time(nullptr));
g_ServiceName = "WorldServer";
// Set this once here before we parse a bunch of options in case we crash early
Diagnostics::SetProcessName(g_ServiceName);
Diagnostics::SetProcessFileName(argv[0]);
Diagnostics::Initialize();
@@ -158,7 +165,13 @@ int main(int argc, char** argv) {
Game::config = new dConfig("worldconfig.ini");
//Create all the objects we need to run our service:
Server::SetupLogger("WorldServer_" + std::to_string(zoneID) + "_" + std::to_string(g_InstanceID));
const auto zoneStr = std::to_string(zoneID);
const auto cloneStr = std::to_string(cloneID);
const auto instanceStr = std::to_string(g_InstanceID);
g_ServiceName += "_" + zoneStr + "_" + cloneStr + "_" + instanceStr + "_" + curTimeStr;
// Here we re-set the process name since it'll have more info now
Diagnostics::SetProcessName(g_ServiceName);
Server::SetupLogger(g_ServiceName, "WorldServer/" + zoneStr + "/" + cloneStr + "/");
if (!Game::logger) return EXIT_FAILURE;
Game::config->LogSettings();
@@ -1586,7 +1599,7 @@ void FinalizeShutdown() {
//Delete our objects here:
dpWorld::Shutdown();
Database::Destroy("WorldServer");
Database::Destroy(g_ServiceName);
if (Game::chatFilter) delete Game::chatFilter;
Game::chatFilter = nullptr;
if (Game::zoneManager) delete Game::zoneManager;