From d659d6f5b4a03f27d0cde7e1fd2f9da60095b5d0 Mon Sep 17 00:00:00 2001 From: swurl Date: Thu, 8 May 2025 06:20:20 +0000 Subject: [PATCH] Runtime option for flushing logs by line (#90) Signed-off-by: swurl Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/90 Co-authored-by: swurl Co-committed-by: swurl --- CMakeLists.txt | 6 -- src/common/logging/backend.cpp | 12 ++-- src/common/settings.h | 1 + src/yuzu/configuration/configure_debug.cpp | 2 + src/yuzu/configuration/configure_debug.ui | 65 ++++++++++++---------- 5 files changed, 45 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41ad4fc07c..b88ab64e53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,8 +73,6 @@ 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) @@ -287,10 +285,6 @@ 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 5ce1c2582e..3b400c6566 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -88,8 +88,8 @@ public: auto old_filename = filename; old_filename += ".old.txt"; - // Existence checks are done within the functions themselves. - // We don't particularly care if these succeed or not. + // Existence checks are done within the functions themselves. + // We don't particularly care if these succeed or not. static_cast(FS::RemoveFile(old_filename)); static_cast(FS::RenameFile(filename, old_filename)); @@ -106,10 +106,10 @@ 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 + // Option to log each line rather than 4k buffers + if (Settings::values.log_flush_lines.GetValue()) { + file->Flush(); + } using namespace Common::Literals; // Prevent logs from exceeding a set maximum size in the event that log entries are spammed. diff --git a/src/common/settings.h b/src/common/settings.h index 646051f24c..709ca03e7c 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -627,6 +627,7 @@ struct Values { // Miscellaneous Setting log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous}; + Setting log_flush_lines{linkage, false, "flush_lines", Category::Miscellaneous}; Setting use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous}; // Network diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index 1010038b76..5f23eea3d3 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -39,6 +39,7 @@ void ConfigureDebug::SetConfiguration() { ui->toggle_console->setEnabled(runtime_lock); ui->toggle_console->setChecked(UISettings::values.show_console.GetValue()); ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter.GetValue())); + ui->flush_line->setChecked(Settings::values.log_flush_lines.GetValue()); ui->homebrew_args_edit->setText( QString::fromStdString(Settings::values.program_args.GetValue())); ui->fs_access_log->setEnabled(runtime_lock); @@ -88,6 +89,7 @@ void ConfigureDebug::ApplyConfiguration() { Settings::values.gdbstub_port = ui->gdbport_spinbox->value(); UISettings::values.show_console = ui->toggle_console->isChecked(); Settings::values.log_filter = ui->log_filter_edit->text().toStdString(); + Settings::values.log_flush_lines = ui->flush_line->isChecked(); Settings::values.program_args = ui->homebrew_args_edit->text().toStdString(); Settings::values.enable_fs_access_log = ui->fs_access_log->isChecked(); Settings::values.reporting_services = ui->reporting_services->isChecked(); diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index d842b01352..68c5a67b24 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -18,8 +18,8 @@ 0 0 - 842 - 741 + 829 + 758 @@ -40,7 +40,7 @@ Debugger - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop false @@ -59,7 +59,7 @@ - QLayout::SetDefaultConstraint + QLayout::SizeConstraint::SetDefaultConstraint 0 @@ -355,10 +355,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Preferred + QSizePolicy::Policy::Preferred @@ -452,10 +452,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -474,37 +474,27 @@ Debugging - - - - Enable FS Access Log - - - - - - Enable this to output the latest generated audio command list to the console. Only affects games using the audio renderer. - - - Dump Audio Commands To Console** - - - - Enable Verbose Reporting Services** - + + + + Enable FS Access Log + + + + - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -514,6 +504,23 @@ + + + + Enable this to output the latest generated audio command list to the console. Only affects games using the audio renderer. + + + Dump Audio Commands To Console** + + + + + + + Flush log output on each line + + + @@ -522,7 +529,7 @@ - Qt::Vertical + Qt::Orientation::Vertical