summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/logging/backend.cpp11
-rw-r--r--src/common/logging/filter.cpp7
-rw-r--r--src/common/logging/filter.h3
3 files changed, 17 insertions, 4 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 242914c6a..ed1e93cc2 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -5,6 +5,7 @@
5#include <algorithm> 5#include <algorithm>
6#include <array> 6#include <array>
7#include <chrono> 7#include <chrono>
8#include <climits>
8#include <condition_variable> 9#include <condition_variable>
9#include <memory> 10#include <memory>
10#include <thread> 11#include <thread>
@@ -83,8 +84,10 @@ private:
83 } 84 }
84 }; 85 };
85 while (true) { 86 while (true) {
86 std::unique_lock<std::mutex> lock(message_mutex); 87 {
87 message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); }); 88 std::unique_lock<std::mutex> lock(message_mutex);
89 message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); });
90 }
88 if (!running) { 91 if (!running) {
89 break; 92 break;
90 } 93 }
@@ -92,7 +95,7 @@ private:
92 } 95 }
93 // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case 96 // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case
94 // where a system is repeatedly spamming logs even on close. 97 // where a system is repeatedly spamming logs even on close.
95 constexpr int MAX_LOGS_TO_WRITE = 100; 98 const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100;
96 int logs_written = 0; 99 int logs_written = 0;
97 while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) { 100 while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) {
98 write_logs(entry); 101 write_logs(entry);
@@ -282,4 +285,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
282 285
283 Impl::Instance().PushEntry(std::move(entry)); 286 Impl::Instance().PushEntry(std::move(entry));
284} 287}
285} // namespace Log \ No newline at end of file 288} // namespace Log
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index 4e783a577..6ed087beb 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -94,4 +94,11 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin,
94bool Filter::CheckMessage(Class log_class, Level level) const { 94bool Filter::CheckMessage(Class log_class, Level level) const {
95 return static_cast<u8>(level) >= static_cast<u8>(class_levels[static_cast<size_t>(log_class)]); 95 return static_cast<u8>(level) >= static_cast<u8>(class_levels[static_cast<size_t>(log_class)]);
96} 96}
97
98bool Filter::IsDebug() const {
99 return std::any_of(class_levels.begin(), class_levels.end(), [](const Level& l) {
100 return static_cast<u8>(l) <= static_cast<u8>(Level::Debug);
101 });
102}
103
97} // namespace Log 104} // namespace Log
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h
index ccca289bd..2a4f7c845 100644
--- a/src/common/logging/filter.h
+++ b/src/common/logging/filter.h
@@ -47,6 +47,9 @@ public:
47 /// Matches class/level combination against the filter, returning true if it passed. 47 /// Matches class/level combination against the filter, returning true if it passed.
48 bool CheckMessage(Class log_class, Level level) const; 48 bool CheckMessage(Class log_class, Level level) const;
49 49
50 /// Returns true if any logging classes are set to debug
51 bool IsDebug() const;
52
50private: 53private:
51 std::array<Level, (size_t)Class::Count> class_levels; 54 std::array<Level, (size_t)Class::Count> class_levels;
52}; 55};