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

@@ -47,7 +47,9 @@ void HandlePacket(Packet* packet);
int main(int argc, char** argv) {
constexpr uint32_t chatFramerate = mediumFramerate;
constexpr uint32_t chatFrameDelta = mediumFrameDelta;
Diagnostics::SetProcessName("Chat");
const auto curTimeStr = std::to_string(time(nullptr));
const auto serviceName = "ChatServer_" + curTimeStr;
Diagnostics::SetProcessName(serviceName);
Diagnostics::SetProcessFileName(argv[0]);
Diagnostics::Initialize();
@@ -57,7 +59,7 @@ int main(int argc, char** argv) {
Game::config = new dConfig("chatconfig.ini");
//Create all the objects we need to run our service:
Server::SetupLogger("ChatServer");
Server::SetupLogger(serviceName, "ChatServer");
if (!Game::logger) return EXIT_FAILURE;
Game::config->LogSettings();
@@ -88,7 +90,7 @@ int main(int argc, char** argv) {
Database::Connect();
} catch (std::exception& ex) {
LOG("Got an error while connecting to the database: %s", ex.what());
Database::Destroy("ChatServer");
Database::Destroy(serviceName);
delete Game::logger;
delete Game::config;
return EXIT_FAILURE;
@@ -99,7 +101,7 @@ int main(int argc, char** argv) {
if (Game::config->GetValue("web_server_enabled") == "1" && !Game::web.Startup("localhost", web_server_port)) {
// if we want the web server and it fails to start, exit
LOG("Failed to start web server, shutting down.");
Database::Destroy("ChatServer");
Database::Destroy(serviceName);
delete Game::logger;
delete Game::config;
return EXIT_FAILURE;
@@ -200,7 +202,7 @@ int main(int argc, char** argv) {
Game::playerContainer.Shutdown();
TeamContainer::Shutdown();
//Delete our objects here:
Database::Destroy("ChatServer");
Database::Destroy(serviceName);
delete Game::server;
Game::server = nullptr;
delete Game::logger;