From bc55ed496f48f8b9f5ecde3d6dfc35d03912ba2e Mon Sep 17 00:00:00 2001 From: Aleksandr Popovich Date: Mon, 19 May 2025 21:29:22 +0000 Subject: [PATCH] add option to censor the username in logs (#111) Signed-off-by: Aleksandr Popovich Co-authored-by: Esther1024 Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/111 Co-authored-by: Aleksandr Popovich Co-committed-by: Aleksandr Popovich --- src/common/logging/backend.cpp | 18 ++++++++-- src/common/settings.h | 1 + src/yuzu/configuration/configure_debug.cpp | 2 ++ src/yuzu/configuration/configure_debug.ui | 39 +++++++++++++--------- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index e5bf6b723a..ff07ab68eb 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -4,8 +4,10 @@ #include #include #include +#include #include +#include #include #ifdef _WIN32 @@ -104,9 +106,21 @@ public: return; } - bytes_written += file->WriteString(FormatLogMessage(entry).append(1, '\n')); + auto message = FormatLogMessage(entry).append(1, '\n'); - // Option to log each line rather than 4k buffers +#ifndef ANDROID + if (Settings::values.censor_username.GetValue()) { + char* username = getenv("USER"); + if (!username) { + username = getenv("USERNAME"); + } + boost::replace_all(message, username, "user"); + } +#endif + + bytes_written += file->WriteString(message); + + // Option to log each line rather than 4k buffers if (Settings::values.log_flush_lines.GetValue()) { file->Flush(); } diff --git a/src/common/settings.h b/src/common/settings.h index 58044103f6..5e0efab8e6 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -633,6 +633,7 @@ struct Values { // Miscellaneous Setting log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous}; Setting log_flush_lines{linkage, false, "flush_lines", Category::Miscellaneous}; + Setting censor_username{linkage, true, "censor_username", Category::Miscellaneous}; Setting use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous}; Setting first_launch{linkage, true, "first_launch", Category::Miscellaneous}; Setting hide_pre_alpha_warning{linkage, diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index bcb8d1fc5e..10607ee233 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -40,6 +40,7 @@ void ConfigureDebug::SetConfiguration() { 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->censor_username->setChecked(Settings::values.censor_username.GetValue()); ui->homebrew_args_edit->setText( QString::fromStdString(Settings::values.program_args.GetValue())); ui->fs_access_log->setEnabled(runtime_lock); @@ -90,6 +91,7 @@ void ConfigureDebug::ApplyConfiguration() { 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.censor_username = ui->censor_username->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 3a54d93b7b..155dac412b 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -474,21 +474,7 @@ Debugging - - - - Enable Verbose Reporting Services** - - - - - - - Enable FS Access Log - - - - + Qt::Orientation::Vertical @@ -504,7 +490,7 @@ - + Enable this to output the latest generated audio command list to the console. Only affects games using the audio renderer. @@ -521,6 +507,27 @@ + + + + Enable FS Access Log + + + + + + + Enable Verbose Reporting Services** + + + + + + + Censor username in logs + + +