|
|
@ -5,6 +5,7 @@
|
|
|
|
#include <algorithm>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <array>
|
|
|
|
#include <array>
|
|
|
|
#include <chrono>
|
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
#include <climits>
|
|
|
|
#include <condition_variable>
|
|
|
|
#include <condition_variable>
|
|
|
|
#include <memory>
|
|
|
|
#include <memory>
|
|
|
|
#include <thread>
|
|
|
|
#include <thread>
|
|
|
@ -83,8 +84,10 @@ private:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
{
|
|
|
|
std::unique_lock<std::mutex> lock(message_mutex);
|
|
|
|
std::unique_lock<std::mutex> lock(message_mutex);
|
|
|
|
message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); });
|
|
|
|
message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); });
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!running) {
|
|
|
|
if (!running) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -92,7 +95,7 @@ private:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case
|
|
|
|
// Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case
|
|
|
|
// where a system is repeatedly spamming logs even on close.
|
|
|
|
// where a system is repeatedly spamming logs even on close.
|
|
|
|
constexpr int MAX_LOGS_TO_WRITE = 100;
|
|
|
|
const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100;
|
|
|
|
int logs_written = 0;
|
|
|
|
int logs_written = 0;
|
|
|
|
while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) {
|
|
|
|
while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) {
|
|
|
|
write_logs(entry);
|
|
|
|
write_logs(entry);
|
|
|
|