mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-01 02:13:44 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user