mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-10 04:40:05 +00:00
Add log regex filter
This commit is contained in:
parent
bf0127d0ae
commit
ea1d63f0ba
8 changed files with 57 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue