add option to censor the username in logs (#111)

Signed-off-by: Aleksandr Popovich <alekpopo@pm.me>
Co-authored-by: Esther1024 <danishreyjavik@outlook.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/111
Co-authored-by: Aleksandr Popovich <alekpopo@pm.me>
Co-committed-by: Aleksandr Popovich <alekpopo@pm.me>
This commit is contained in:
Aleksandr Popovich 2025-05-19 21:29:22 +00:00 committed by AlekPop
parent 244c07c999
commit bc55ed496f
4 changed files with 42 additions and 18 deletions

View file

@ -4,8 +4,10 @@
#include <atomic>
#include <chrono>
#include <climits>
#include <regex>
#include <thread>
#include <boost/algorithm/string/replace.hpp>
#include <fmt/ranges.h>
#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();
}

View file

@ -633,6 +633,7 @@ struct Values {
// Miscellaneous
Setting<std::string> log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous};
Setting<bool> log_flush_lines{linkage, false, "flush_lines", Category::Miscellaneous};
Setting<bool> censor_username{linkage, true, "censor_username", Category::Miscellaneous};
Setting<bool> use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous};
Setting<bool> first_launch{linkage, true, "first_launch", Category::Miscellaneous};
Setting<bool> hide_pre_alpha_warning{linkage,

View file

@ -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();

View file

@ -474,21 +474,7 @@
<string>Debugging</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="0">
<widget class="QCheckBox" name="reporting_services">
<property name="text">
<string>Enable Verbose Reporting Services**</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="fs_access_log">
<property name="text">
<string>Enable FS Access Log</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
@ -504,7 +490,7 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QCheckBox" name="dump_audio_commands">
<property name="toolTip">
<string>Enable this to output the latest generated audio command list to the console. Only affects games using the audio renderer.</string>
@ -521,6 +507,27 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="fs_access_log">
<property name="text">
<string>Enable FS Access Log</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="reporting_services">
<property name="text">
<string>Enable Verbose Reporting Services**</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="censor_username">
<property name="text">
<string>Censor username in logs</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>