From d835e18c92856eef51974d24c7607699837dbace Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Sun, 27 Sep 2026 09:39:53 -0500 Subject: [PATCH] fix: follow main's log folders in the dashboard and UGC server Servers now log to logs// (worlds to logs/WorldServer///) with the start time in the file name. The dashboard and UGC server log the same way, and the System Log page and log search read the whole folder tree instead of only the top of logs/. Co-Authored-By: Claude Opus 5.5 --- dDashboardServer/DashboardServer.cpp | 3 ++- dDashboardServer/routes/DashboardRoutes.cpp | 6 ++++-- dDashboardServer/routes/ServerRoutes.cpp | 8 +++++--- dUgcServer/UgcServer.cpp | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dDashboardServer/DashboardServer.cpp b/dDashboardServer/DashboardServer.cpp index 19d08e381..a68548853 100644 --- a/dDashboardServer/DashboardServer.cpp +++ b/dDashboardServer/DashboardServer.cpp @@ -350,7 +350,8 @@ int main(int argc, char** argv) { Game::config = new dConfig("dashboardconfig.ini"); // Setup logger - Server::SetupLogger("DashboardServer"); + // Like the other servers: logs/DashboardServer/DashboardServer_.log + Server::SetupLogger("DashboardServer_" + std::to_string(time(nullptr)), "DashboardServer"); if (!Game::logger) return EXIT_FAILURE; Game::config->LogSettings(); diff --git a/dDashboardServer/routes/DashboardRoutes.cpp b/dDashboardServer/routes/DashboardRoutes.cpp index f04ef5c2c..7786a51c8 100644 --- a/dDashboardServer/routes/DashboardRoutes.cpp +++ b/dDashboardServer/routes/DashboardRoutes.cpp @@ -228,12 +228,14 @@ namespace { uintmax_t size{}; }; - // Every log file, by server (the name before the start time, e.g. "WorldServer_1200_3"), newest first + // Every log file, by server (the name before the start time, e.g. "WorldServer_1200_0_3"), newest first. Servers + // write into their own folders (logs/WorldServer///, logs/AuthServer/, ...), so the whole tree is read. std::map> LogFilesByServer() { std::map> byServer; const auto logDir = BinaryPathFinder::GetBinaryDir() / "logs"; std::error_code ec; - for (const auto& entry : std::filesystem::directory_iterator(logDir, ec)) { + for (auto it = std::filesystem::recursive_directory_iterator(logDir, ec); !ec && it != std::filesystem::recursive_directory_iterator(); it.increment(ec)) { + const auto& entry = *it; if (!entry.is_regular_file(ec) || entry.path().extension() != ".log") continue; const auto stem = entry.path().stem().string(); const auto written = std::chrono::duration_cast( diff --git a/dDashboardServer/routes/ServerRoutes.cpp b/dDashboardServer/routes/ServerRoutes.cpp index 4b16d72ed..5b882e3fd 100644 --- a/dDashboardServer/routes/ServerRoutes.cpp +++ b/dDashboardServer/routes/ServerRoutes.cpp @@ -135,7 +135,7 @@ void RegisterServerRoutes() { Route(eHTTPMethod::GET, "/api/crash_dumps/:name", Perm("logs_system"), "Download a crash dump", [](HTTPReply& reply, const HTTPContext& context) { - const std::string name(PathSegment(context.originalPath, 2)); // crash_World_123.log: case matters + const std::string name(PathSegment(context.originalPath, 2)); // Crash_WorldServer_..._123.log: case matters const auto folder = DumpFolder(); if (folder.empty() || !PlainFileName(name)) return JsonError(reply, eHTTPStatusCode::NOT_FOUND, "Not found"); std::error_code ec; @@ -159,10 +159,12 @@ void RegisterServerRoutes() { const auto folder = LogFolder(); const auto requestId = PlayerActions::Begin(context.accountId, std::chrono::minutes(5)); Background::Run("log_search:" + std::to_string(requestId), [folder, query, server, perServer](GameDatabase&) -> nlohmann::json { - // Newest files of each server (file names: _