From b2b035dccae6d842c60ce377171be29e0fede9b0 Mon Sep 17 00:00:00 2001 From: swurl Date: Thu, 24 Apr 2025 10:58:22 -0400 Subject: [PATCH] Log by line compilation option Signed-off-by: swurl --- .ci/linux.sh | 1 + CMakeLists.txt | 7 +++++++ src/common/logging/backend.cpp | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/.ci/linux.sh b/.ci/linux.sh index 88e9cb489e..694e1c5b2a 100755 --- a/.ci/linux.sh +++ b/.ci/linux.sh @@ -49,6 +49,7 @@ cmake .. -G Ninja \ -DYUZU_USE_BUNDLED_VCPKG=OFF \ -DYUZU_USE_BUNDLED_QT=OFF \ -DUSE_SYSTEM_QT=ON \ + -DYUZU_LOG_BY_LINE=ON \ -DYUZU_USE_BUNDLED_FFMPEG=OFF \ -DYUZU_USE_BUNDLED_SDL2=OFF \ -DYUZU_USE_EXTERNAL_SDL2=ON \ diff --git a/CMakeLists.txt b/CMakeLists.txt index b88ab64e53..ed65690826 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,8 @@ option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF) option(YUZU_DOWNLOAD_TIME_ZONE_DATA "Always download time zone binaries" OFF) +option(YUZU_LOG_BY_LINE "Flush log data by the line rather than 4KB buffers" OFF) + option(YUZU_ENABLE_PORTABLE "Allow yuzu to enable portable mode if a user folder is found in the CWD" ON) CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF) @@ -285,6 +287,11 @@ if (ARCHITECTURE_arm64 AND (ANDROID OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")) add_definitions(-DHAS_NCE=1) endif() +if (YUZU_LOG_BY_LINE) + add_definitions(-DYUZU_LOG_BY_LINE=1) +endif() + + # Configure C++ standard # =========================== diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 291847fcf8..5ce1c2582e 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -106,6 +106,11 @@ public: bytes_written += file->WriteString(FormatLogMessage(entry).append(1, '\n')); + // Option to log each line rather than 4k buffers +#ifdef YUZU_LOG_BY_LINE + file->Flush(); +#endif + using namespace Common::Literals; // Prevent logs from exceeding a set maximum size in the event that log entries are spammed. const auto write_limit = Settings::values.extended_logging.GetValue() ? 1_GiB : 100_MiB;