Toggle to enable/disable logging (#3493)

* Update config.cpp

* Update config.h

* Update backend.cpp

* Update settings_dialog.cpp

* Update settings_dialog.ui

* fix clang settings_dialog.cpp

* fix description in settings_dialog.cpp

* added back the backslash settings_dialog.cpp

* move enable logging and separate log files to logger settings_dialog.ui
This commit is contained in:
UltraDaCat
2025-08-31 22:11:49 +02:00
committed by GitHub
parent e6f0ee7ed2
commit ba65408608
5 changed files with 56 additions and 26 deletions

View File

@@ -96,6 +96,7 @@ static bool isDebugDump = false;
static bool isShaderDebug = false; static bool isShaderDebug = false;
static bool isSeparateLogFilesEnabled = false; static bool isSeparateLogFilesEnabled = false;
static bool isFpsColor = true; static bool isFpsColor = true;
static bool logEnabled = true;
// GUI // GUI
static bool load_game_size = true; static bool load_game_size = true;
@@ -140,6 +141,10 @@ int* GetControllerCustomColor() {
return controllerCustomColorRGB; return controllerCustomColorRGB;
} }
bool getLoggingEnabled() {
return logEnabled;
}
void SetControllerCustomColor(int r, int b, int g) { void SetControllerCustomColor(int r, int b, int g) {
controllerCustomColorRGB[0] = r; controllerCustomColorRGB[0] = r;
controllerCustomColorRGB[1] = b; controllerCustomColorRGB[1] = b;
@@ -313,6 +318,10 @@ bool fpsColor() {
return isFpsColor; return isFpsColor;
} }
bool isLoggingEnabled() {
return logEnabled;
}
u32 vblankDiv() { u32 vblankDiv() {
return vblankDivider; return vblankDivider;
} }
@@ -389,6 +398,10 @@ void setDebugDump(bool enable) {
isDebugDump = enable; isDebugDump = enable;
} }
void setLoggingEnabled(bool enable) {
logEnabled = enable;
}
void setCollectShaderForDebug(bool enable) { void setCollectShaderForDebug(bool enable) {
isShaderDebug = enable; isShaderDebug = enable;
} }
@@ -738,6 +751,7 @@ void load(const std::filesystem::path& path) {
toml::find_or<bool>(debug, "isSeparateLogFilesEnabled", isSeparateLogFilesEnabled); toml::find_or<bool>(debug, "isSeparateLogFilesEnabled", isSeparateLogFilesEnabled);
isShaderDebug = toml::find_or<bool>(debug, "CollectShader", isShaderDebug); isShaderDebug = toml::find_or<bool>(debug, "CollectShader", isShaderDebug);
isFpsColor = toml::find_or<bool>(debug, "FPSColor", isFpsColor); isFpsColor = toml::find_or<bool>(debug, "FPSColor", isFpsColor);
logEnabled = toml::find_or<bool>(debug, "logEnabled", logEnabled);
current_version = toml::find_or<std::string>(debug, "ConfigVersion", current_version); current_version = toml::find_or<std::string>(debug, "ConfigVersion", current_version);
} }
@@ -893,6 +907,7 @@ void save(const std::filesystem::path& path) {
data["Debug"]["CollectShader"] = isShaderDebug; data["Debug"]["CollectShader"] = isShaderDebug;
data["Debug"]["isSeparateLogFilesEnabled"] = isSeparateLogFilesEnabled; data["Debug"]["isSeparateLogFilesEnabled"] = isSeparateLogFilesEnabled;
data["Debug"]["FPSColor"] = isFpsColor; data["Debug"]["FPSColor"] = isFpsColor;
data["Debug"]["logEnabled"] = logEnabled;
data["Debug"]["ConfigVersion"] = config_version; data["Debug"]["ConfigVersion"] = config_version;
data["Keys"]["TrophyKey"] = trophyKey; data["Keys"]["TrophyKey"] = trophyKey;
@@ -1005,6 +1020,7 @@ void setDefaultValues() {
isShaderDebug = false; isShaderDebug = false;
isSeparateLogFilesEnabled = false; isSeparateLogFilesEnabled = false;
isFpsColor = true; isFpsColor = true;
logEnabled = true;
// GUI // GUI
load_game_size = true; load_game_size = true;

View File

@@ -111,6 +111,8 @@ std::string getDefaultControllerID();
void setDefaultControllerID(std::string id); void setDefaultControllerID(std::string id);
bool getBackgroundControllerInput(); bool getBackgroundControllerInput();
void setBackgroundControllerInput(bool enable); void setBackgroundControllerInput(bool enable);
bool getLoggingEnabled();
void setLoggingEnabled(bool enable);
// TODO // TODO
bool GetLoadGameSizeEnabled(); bool GetLoadGameSizeEnabled();

View File

@@ -191,7 +191,7 @@ public:
} }
} }
if (!filter.CheckMessage(log_class, log_level)) { if (!filter.CheckMessage(log_class, log_level) || !Config::getLoggingEnabled()) {
return; return;
} }

View File

@@ -428,6 +428,7 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
ui->readbacksCheckBox->installEventFilter(this); ui->readbacksCheckBox->installEventFilter(this);
ui->readbackLinearImagesCheckBox->installEventFilter(this); ui->readbackLinearImagesCheckBox->installEventFilter(this);
ui->separateLogFilesCheckbox->installEventFilter(this); ui->separateLogFilesCheckbox->installEventFilter(this);
ui->enableLoggingCheckBox->installEventFilter(this);
} }
} }
@@ -547,6 +548,7 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->collectShaderCheckBox->setChecked( ui->collectShaderCheckBox->setChecked(
toml::find_or<bool>(data, "Debug", "CollectShader", false)); toml::find_or<bool>(data, "Debug", "CollectShader", false));
ui->readbacksCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "readbacks", false)); ui->readbacksCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "readbacks", false));
ui->enableLoggingCheckBox->setChecked(toml::find_or<bool>(data, "Debug", "logEnabled", true));
ui->readbackLinearImagesCheckBox->setChecked( ui->readbackLinearImagesCheckBox->setChecked(
toml::find_or<bool>(data, "GPU", "readbackLinearImages", false)); toml::find_or<bool>(data, "GPU", "readbackLinearImages", false));
ui->enableCompatibilityCheckBox->setChecked( ui->enableCompatibilityCheckBox->setChecked(
@@ -774,7 +776,9 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
} else if (elementName == "readbackLinearImagesCheckBox") { } else if (elementName == "readbackLinearImagesCheckBox") {
text = tr("Enable Readback Linear Images:\\nEnables async downloading of GPU modified linear images.\\nMight fix issues in some games."); text = tr("Enable Readback Linear Images:\\nEnables async downloading of GPU modified linear images.\\nMight fix issues in some games.");
} else if (elementName == "separateLogFilesCheckbox") { } else if (elementName == "separateLogFilesCheckbox") {
text = tr("Separate Log Files:\\nWrites a separate logfile for each game.");} text = tr("Separate Log Files:\\nWrites a separate logfile for each game.");
} else if (elementName == "enableLoggingCheckBox") {
text = tr("Enable Logging:\\nEnables logging.\\nDo not change this if you do not know what you're doing!\\nWhen asking for help, make sure this setting is ENABLED."); }
// clang-format on // clang-format on
ui->descriptionText->setText(text.replace("\\n", "\n")); ui->descriptionText->setText(text.replace("\\n", "\n"));
} }
@@ -816,6 +820,7 @@ void SettingsDialog::UpdateSettings() {
Config::setSideTrophy("bottom"); Config::setSideTrophy("bottom");
} }
m_gui_settings->SetValue(gui::gl_playBackgroundMusic, ui->playBGMCheckBox->isChecked()); m_gui_settings->SetValue(gui::gl_playBackgroundMusic, ui->playBGMCheckBox->isChecked());
Config::setLoggingEnabled(ui->enableLoggingCheckBox->isChecked());
Config::setAllowHDR(ui->enableHDRCheckBox->isChecked()); Config::setAllowHDR(ui->enableHDRCheckBox->isChecked());
Config::setLogType(logTypeMap.value(ui->logTypeComboBox->currentText()).toStdString()); Config::setLogType(logTypeMap.value(ui->logTypeComboBox->currentText()).toStdString());
Config::setMicDevice(ui->micComboBox->currentData().toString().toStdString()); Config::setMicDevice(ui->micComboBox->currentData().toString().toStdString());

View File

@@ -59,7 +59,7 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>6</number>
</property> </property>
<widget class="QScrollArea" name="generalTab"> <widget class="QScrollArea" name="generalTab">
<property name="widgetResizable"> <property name="widgetResizable">
@@ -73,8 +73,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>679</width>
<height>536</height> <height>420</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="generalTabVLayout" stretch="0"> <layout class="QVBoxLayout" name="generalTabVLayout" stretch="0">
@@ -369,8 +369,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>149</width>
<height>68</height> <height>69</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
@@ -538,8 +538,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>626</width>
<height>536</height> <height>370</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="guiTabVLayout" stretch="0"> <layout class="QVBoxLayout" name="guiTabVLayout" stretch="0">
@@ -987,8 +987,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>553</width>
<height>536</height> <height>244</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0"> <layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0">
@@ -1282,8 +1282,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>485</width>
<height>536</height> <height>348</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="userTabVLayout" stretch="0,0,1"> <layout class="QVBoxLayout" name="userTabVLayout" stretch="0,0,1">
@@ -1524,8 +1524,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>515</width>
<height>536</height> <height>228</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0"> <layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0">
@@ -1796,8 +1796,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>421</width>
<height>536</height> <height>319</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="pathsTabLayout"> <layout class="QVBoxLayout" name="pathsTabLayout">
@@ -1938,8 +1938,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>944</width>
<height>536</height> <height>537</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,0"> <layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,0">
@@ -2013,6 +2013,20 @@
<string>Logger</string> <string>Logger</string>
</property> </property>
<layout class="QVBoxLayout" name="loggerLayout"> <layout class="QVBoxLayout" name="loggerLayout">
<item>
<widget class="QCheckBox" name="enableLoggingCheckBox">
<property name="text">
<string>Enable Logging</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="separateLogFilesCheckbox">
<property name="text">
<string>Separate Log Files</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="LogTypeWidget" native="true"> <widget class="QWidget" name="LogTypeWidget" native="true">
<layout class="QVBoxLayout" name="LogTypeLayout"> <layout class="QVBoxLayout" name="LogTypeLayout">
@@ -2146,13 +2160,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="separateLogFilesCheckbox">
<property name="text">
<string>Separate Log Files</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>