Add log regex filter
This commit is contained in:
parent
469f76b075
commit
a110843115
8 changed files with 56 additions and 2 deletions
|
@ -244,12 +244,14 @@ void Config::ReadValues() {
|
|||
|
||||
// Miscellaneous
|
||||
ReadSetting("Miscellaneous", Settings::values.log_filter);
|
||||
ReadSetting("Miscellaneous", Settings::values.log_regex_filter);
|
||||
|
||||
// Apply the log_filter setting as the logger has already been initialized
|
||||
// and doesn't pick up the filter on its own.
|
||||
Common::Log::Filter filter;
|
||||
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
||||
Common::Log::SetGlobalFilter(filter);
|
||||
Common::Log::SetRegexFilter(Settings::values.log_regex_filter.GetValue());
|
||||
|
||||
// Debugging
|
||||
Settings::values.record_frame_times =
|
||||
|
|
|
@ -306,12 +306,14 @@ void Config::ReadValues() {
|
|||
|
||||
// Miscellaneous
|
||||
ReadSetting("Miscellaneous", Settings::values.log_filter);
|
||||
ReadSetting("Miscellaneous", Settings::values.log_regex_filter);
|
||||
|
||||
// Apply the log_filter setting as the logger has already been initialized
|
||||
// and doesn't pick up the filter on its own.
|
||||
Common::Log::Filter filter;
|
||||
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
||||
Common::Log::SetGlobalFilter(filter);
|
||||
Common::Log::SetRegexFilter(Settings::values.log_regex_filter.GetValue());
|
||||
|
||||
// Debugging
|
||||
Settings::values.record_frame_times =
|
||||
|
|
|
@ -531,6 +531,7 @@ void Config::ReadMiscellaneousValues() {
|
|||
qt_config->beginGroup(QStringLiteral("Miscellaneous"));
|
||||
|
||||
ReadBasicSetting(Settings::values.log_filter);
|
||||
ReadBasicSetting(Settings::values.log_regex_filter);
|
||||
ReadBasicSetting(Settings::values.enable_gamemode);
|
||||
|
||||
qt_config->endGroup();
|
||||
|
@ -1054,6 +1055,7 @@ void Config::SaveMiscellaneousValues() {
|
|||
qt_config->beginGroup(QStringLiteral("Miscellaneous"));
|
||||
|
||||
WriteBasicSetting(Settings::values.log_filter);
|
||||
WriteBasicSetting(Settings::values.log_regex_filter);
|
||||
WriteBasicSetting(Settings::values.enable_gamemode);
|
||||
|
||||
qt_config->endGroup();
|
||||
|
|
|
@ -97,6 +97,8 @@ void ConfigureDebug::SetConfiguration() {
|
|||
ui->toggle_console->setEnabled(!is_powered_on);
|
||||
ui->toggle_console->setChecked(UISettings::values.show_console.GetValue());
|
||||
ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter.GetValue()));
|
||||
ui->log_regex_filter_edit->setText(
|
||||
QString::fromStdString(Settings::values.log_regex_filter.GetValue()));
|
||||
ui->toggle_cpu_jit->setChecked(Settings::values.use_cpu_jit.GetValue());
|
||||
ui->delay_start_for_lle_modules->setChecked(
|
||||
Settings::values.delay_start_for_lle_modules.GetValue());
|
||||
|
@ -126,10 +128,12 @@ 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_regex_filter = ui->log_regex_filter_edit->text().toStdString();
|
||||
Debugger::ToggleConsole();
|
||||
Common::Log::Filter filter;
|
||||
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
||||
Common::Log::SetGlobalFilter(filter);
|
||||
Common::Log::SetRegexFilter(Settings::values.log_regex_filter.GetValue());
|
||||
Settings::values.use_cpu_jit = ui->toggle_cpu_jit->isChecked();
|
||||
Settings::values.delay_start_for_lle_modules = ui->delay_start_for_lle_modules->isChecked();
|
||||
Settings::values.renderer_debug = ui->toggle_renderer_debug->isChecked();
|
||||
|
|
|
@ -85,6 +85,20 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Regex Log Filter</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="log_regex_filter_edit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include <chrono>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
|
@ -234,6 +235,19 @@ public:
|
|||
filter = f;
|
||||
}
|
||||
|
||||
bool SetRegexFilter(const std::string& regex) {
|
||||
if (regex.empty()) {
|
||||
regex_filter = boost::regex();
|
||||
return true;
|
||||
}
|
||||
regex_filter = boost::regex(regex, boost::regex_constants::no_except);
|
||||
if (regex_filter.status() != 0) {
|
||||
regex_filter = boost::regex();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetColorConsoleBackendEnabled(bool enabled) {
|
||||
color_console_backend.SetEnabled(enabled);
|
||||
}
|
||||
|
@ -243,8 +257,13 @@ public:
|
|||
if (!filter.CheckMessage(log_class, log_level)) {
|
||||
return;
|
||||
}
|
||||
message_queue.EmplaceWait(
|
||||
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message)));
|
||||
Entry new_entry =
|
||||
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message));
|
||||
if (!regex_filter.empty() &&
|
||||
!boost::regex_search(FormatLogMessage(new_entry), regex_filter)) {
|
||||
return;
|
||||
}
|
||||
message_queue.EmplaceWait(new_entry);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -406,6 +425,7 @@ private:
|
|||
static inline std::unique_ptr<Impl, decltype(&Deleter)> instance{nullptr, Deleter};
|
||||
|
||||
Filter filter;
|
||||
boost::regex regex_filter;
|
||||
DebuggerBackend debugger_backend{};
|
||||
ColorConsoleBackend color_console_backend{};
|
||||
FileBackend file_backend;
|
||||
|
@ -446,6 +466,10 @@ void SetGlobalFilter(const Filter& filter) {
|
|||
Impl::Instance().SetGlobalFilter(filter);
|
||||
}
|
||||
|
||||
bool SetRegexFilter(const std::string& regex) {
|
||||
return Impl::Instance().SetRegexFilter(regex);
|
||||
}
|
||||
|
||||
void SetColorConsoleBackendEnabled(bool enabled) {
|
||||
Impl::Instance().SetColorConsoleBackendEnabled(enabled);
|
||||
}
|
||||
|
|
|
@ -26,5 +26,10 @@ void DisableLoggingInTests();
|
|||
*/
|
||||
void SetGlobalFilter(const Filter& filter);
|
||||
|
||||
/**
|
||||
* Only allow messages that match the specified regex. The regex is matched against the final log text.
|
||||
*/
|
||||
bool SetRegexFilter(const std::string& regex);
|
||||
|
||||
void SetColorConsoleBackendEnabled(bool enabled);
|
||||
} // namespace Common::Log
|
||||
|
|
|
@ -542,6 +542,7 @@ struct Values {
|
|||
|
||||
// Miscellaneous
|
||||
Setting<std::string> log_filter{"*:Info", "log_filter"};
|
||||
Setting<std::string> log_regex_filter{"", "log_regex_filter"};
|
||||
|
||||
// Video Dumping
|
||||
std::string output_format;
|
||||
|
|
Loading…
Reference in a new issue