From c4d91dfd6c50362dc25c559871cacd3d23b232d4 Mon Sep 17 00:00:00 2001 From: Richard Fortier Date: Sun, 4 Jan 2026 10:40:26 -0500 Subject: [PATCH 1/3] Update to PR #727, further improves multithreaded logging In addition to console window, make sure file logs contain the millisecond and thread ID. Flushes server console log every 2 seconds. Flushes client log every 1s. Will need to separately determine why the flush of the log when crashing doesn't work. But this is good-enough for tail'ing the client log file, and somewhat lower overhead then flushing on every line. Added date to timestamp, which will help us detect when someone sends us the wrong log for a bug. --- Code/client/TiltedOnlineApp.cpp | 4 +++- Code/server_runner/main.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Code/client/TiltedOnlineApp.cpp b/Code/client/TiltedOnlineApp.cpp index 647616e14..45717cb96 100644 --- a/Code/client/TiltedOnlineApp.cpp +++ b/Code/client/TiltedOnlineApp.cpp @@ -36,9 +36,11 @@ TiltedOnlineApp::TiltedOnlineApp() auto rotatingLogger = std::make_shared(logPath / "tp_client.log", 1048576 * 5, 3); // rotatingLogger->set_level(spdlog::level::debug); auto console = std::make_shared(); - console->set_pattern("%^[%H:%M:%S.%e] [%l] [tid %t] %$ %v"); + console->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] [tid %t] %$ %v"); auto logger = std::make_shared("", spdlog::sinks_init_list{console, rotatingLogger}); + logger->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] [tid %t] %$ %v"); + spdlog::flush_every(std::chrono::seconds(1)); set_default_logger(logger); } diff --git a/Code/server_runner/main.cpp b/Code/server_runner/main.cpp index 5916f71f0..d8b27dd5f 100644 --- a/Code/server_runner/main.cpp +++ b/Code/server_runner/main.cpp @@ -65,9 +65,12 @@ struct LogInstance auto fileOut = std::make_shared(std::string("logs/") + kLogFileName, kLogFileSizeCap, 3); auto serverOut = std::make_shared(); - serverOut->set_pattern("%^[%H:%M:%S.%e] [%l] [tid %t] %$ %v"); + serverOut->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] [tid %t] %$ %v"); auto globalOut = std::make_shared("", sinks_init_list{serverOut, fileOut}); + globalOut->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] [tid %t] %$ %v"); + globalOut->set_level(level::from_str(sLogLevel.value())); + spdlog::flush_every(std::chrono::seconds(2)); // as the library is compiled into the client + server we have to do this twice spdlog::set_default_logger(globalOut); From 41a7ee0c67360b2502fed3b24024b2d05a30e067 Mon Sep 17 00:00:00 2001 From: Daniil Date: Sun, 15 Feb 2026 13:38:58 +0300 Subject: [PATCH 2/3] Remove redundant `set_pattern` --- Code/client/TiltedOnlineApp.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Code/client/TiltedOnlineApp.cpp b/Code/client/TiltedOnlineApp.cpp index 45717cb96..63764e0b7 100644 --- a/Code/client/TiltedOnlineApp.cpp +++ b/Code/client/TiltedOnlineApp.cpp @@ -36,8 +36,6 @@ TiltedOnlineApp::TiltedOnlineApp() auto rotatingLogger = std::make_shared(logPath / "tp_client.log", 1048576 * 5, 3); // rotatingLogger->set_level(spdlog::level::debug); auto console = std::make_shared(); - console->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] [tid %t] %$ %v"); - auto logger = std::make_shared("", spdlog::sinks_init_list{console, rotatingLogger}); logger->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] [tid %t] %$ %v"); spdlog::flush_every(std::chrono::seconds(1)); From 1ea592951a3780b746378a754158eaef549ddb55 Mon Sep 17 00:00:00 2001 From: Daniil Date: Sun, 15 Feb 2026 13:39:16 +0300 Subject: [PATCH 3/3] Remove redundant `set_pattern` --- Code/server_runner/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Code/server_runner/main.cpp b/Code/server_runner/main.cpp index d8b27dd5f..07ec13d72 100644 --- a/Code/server_runner/main.cpp +++ b/Code/server_runner/main.cpp @@ -65,7 +65,6 @@ struct LogInstance auto fileOut = std::make_shared(std::string("logs/") + kLogFileName, kLogFileSizeCap, 3); auto serverOut = std::make_shared(); - serverOut->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] [tid %t] %$ %v"); auto globalOut = std::make_shared("", sinks_init_list{serverOut, fileOut}); globalOut->set_pattern("%^[%Y-%m-%d %H:%M:%S.%e] [%l] [tid %t] %$ %v");