1
0
Fork 0
forked from suyu/suyu

Merge pull request #4451 from slashiee/extended-logging

logging/settings: Increase maximum log size to 100 MB and add extended logging option
This commit is contained in:
bunnei 2020-11-23 13:34:15 -08:00 committed by GitHub
commit 5d1447897a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 11 deletions

View file

@ -23,6 +23,7 @@
#include "common/logging/text_formatter.h" #include "common/logging/text_formatter.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "common/threadsafe_queue.h" #include "common/threadsafe_queue.h"
#include "core/settings.h"
namespace Log { namespace Log {
@ -152,10 +153,19 @@ FileBackend::FileBackend(const std::string& filename)
void FileBackend::Write(const Entry& entry) { void FileBackend::Write(const Entry& entry) {
// prevent logs from going over the maximum size (in case its spamming and the user doesn't // prevent logs from going over the maximum size (in case its spamming and the user doesn't
// know) // know)
constexpr std::size_t MAX_BYTES_WRITTEN = 50 * 1024L * 1024L; constexpr std::size_t MAX_BYTES_WRITTEN = 100 * 1024 * 1024;
if (!file.IsOpen() || bytes_written > MAX_BYTES_WRITTEN) { constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1024 * 1024 * 1024;
if (!file.IsOpen()) {
return; return;
} }
if (Settings::values.extended_logging && bytes_written > MAX_BYTES_WRITTEN_EXTENDED) {
return;
} else if (!Settings::values.extended_logging && bytes_written > MAX_BYTES_WRITTEN) {
return;
}
bytes_written += file.WriteString(FormatLogMessage(entry).append(1, '\n')); bytes_written += file.WriteString(FormatLogMessage(entry).append(1, '\n'));
if (entry.log_level >= Level::Error) { if (entry.log_level >= Level::Error) {
file.Flush(); file.Flush();

View file

@ -215,6 +215,7 @@ struct Values {
bool reporting_services; bool reporting_services;
bool quest_flag; bool quest_flag;
bool disable_macro_jit; bool disable_macro_jit;
bool extended_logging;
// Misceallaneous // Misceallaneous
std::string log_filter; std::string log_filter;

View file

@ -649,6 +649,8 @@ void Config::ReadDebuggingValues() {
Settings::values.quest_flag = ReadSetting(QStringLiteral("quest_flag"), false).toBool(); Settings::values.quest_flag = ReadSetting(QStringLiteral("quest_flag"), false).toBool();
Settings::values.disable_macro_jit = Settings::values.disable_macro_jit =
ReadSetting(QStringLiteral("disable_macro_jit"), false).toBool(); ReadSetting(QStringLiteral("disable_macro_jit"), false).toBool();
Settings::values.extended_logging =
ReadSetting(QStringLiteral("extended_logging"), false).toBool();
qt_config->endGroup(); qt_config->endGroup();
} }

View file

@ -41,6 +41,7 @@ void ConfigureDebug::SetConfiguration() {
ui->enable_graphics_debugging->setChecked(Settings::values.renderer_debug); ui->enable_graphics_debugging->setChecked(Settings::values.renderer_debug);
ui->disable_macro_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); ui->disable_macro_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn());
ui->disable_macro_jit->setChecked(Settings::values.disable_macro_jit); ui->disable_macro_jit->setChecked(Settings::values.disable_macro_jit);
ui->extended_logging->setChecked(Settings::values.extended_logging);
} }
void ConfigureDebug::ApplyConfiguration() { void ConfigureDebug::ApplyConfiguration() {
@ -53,6 +54,7 @@ void ConfigureDebug::ApplyConfiguration() {
Settings::values.quest_flag = ui->quest_flag->isChecked(); Settings::values.quest_flag = ui->quest_flag->isChecked();
Settings::values.renderer_debug = ui->enable_graphics_debugging->isChecked(); Settings::values.renderer_debug = ui->enable_graphics_debugging->isChecked();
Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked(); Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked();
Settings::values.extended_logging = ui->extended_logging->isChecked();
Debugger::ToggleConsole(); Debugger::ToggleConsole();
Log::Filter filter; Log::Filter filter;
filter.ParseFilterString(Settings::values.log_filter); filter.ParseFilterString(Settings::values.log_filter);

View file

@ -90,7 +90,7 @@
<item> <item>
<widget class="QCheckBox" name="toggle_console"> <widget class="QCheckBox" name="toggle_console">
<property name="text"> <property name="text">
<string>Show Log Console (Windows Only)</string> <string>Show Log in Console</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -103,6 +103,34 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="extended_logging">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>When checked, the max size of the log increases from 100 MB to 1 GB</string>
</property>
<property name="text">
<string>Enable Extended Logging</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>This will be reset automatically when yuzu closes.</string>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -115,7 +143,7 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Arguments String</string> <string>Arguments String</string>
</property> </property>
@ -140,8 +168,8 @@
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="whatsThis"> <property name="toolTip">
<string>When checked, the graphics API enters in a slower debugging mode</string> <string>When checked, the graphics API enters a slower debugging mode</string>
</property> </property>
<property name="text"> <property name="text">
<string>Enable Graphics Debugging</string> <string>Enable Graphics Debugging</string>
@ -153,8 +181,8 @@
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="whatsThis"> <property name="toolTip">
<string>When checked, it disables the macro Just In Time compiler. Enabled this makes games run slower</string> <string>When checked, it disables the macro Just In Time compiler. Enabling this makes games run slower</string>
</property> </property>
<property name="text"> <property name="text">
<string>Disable Macro JIT</string> <string>Disable Macro JIT</string>
@ -169,7 +197,7 @@
<property name="title"> <property name="title">
<string>Dump</string> <string>Dump</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<widget class="QCheckBox" name="reporting_services"> <widget class="QCheckBox" name="reporting_services">
<property name="text"> <property name="text">
@ -178,7 +206,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label_5">
<property name="font"> <property name="font">
<font> <font>
<italic>true</italic> <italic>true</italic>
@ -200,7 +228,7 @@
<property name="title"> <property name="title">
<string>Advanced</string> <string>Advanced</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item> <item>
<widget class="QCheckBox" name="quest_flag"> <widget class="QCheckBox" name="quest_flag">
<property name="text"> <property name="text">