summaryrefslogtreecommitdiff
path: root/src/common/logging/backend.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-07-15 12:58:52 -0700
committerGravatar GitHub2018-07-15 12:58:52 -0700
commit04b9cde4f5a59e55ae7daac20f79121f8c7e0386 (patch)
tree64528e1b2ced65cf0f9a1a22ffaedabb069fa13d /src/common/logging/backend.cpp
parentMerge pull request #666 from bunnei/g8r8 (diff)
parentLogging: Dump all logs in the queue on close in debug mode (diff)
downloadyuzu-04b9cde4f5a59e55ae7daac20f79121f8c7e0386.tar.gz
yuzu-04b9cde4f5a59e55ae7daac20f79121f8c7e0386.tar.xz
yuzu-04b9cde4f5a59e55ae7daac20f79121f8c7e0386.zip
Merge pull request #664 from jroweboy/logging-stuff
Minor logging improvements
Diffstat (limited to 'src/common/logging/backend.cpp')
-rw-r--r--src/common/logging/backend.cpp11
1 files changed, 7 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