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: _