|
|
@ -4,6 +4,7 @@
|
|
|
|
#include <atomic>
|
|
|
|
#include <atomic>
|
|
|
|
#include <chrono>
|
|
|
|
#include <chrono>
|
|
|
|
#include <climits>
|
|
|
|
#include <climits>
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <thread>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include <fmt/format.h>
|
|
|
@ -231,8 +232,15 @@ public:
|
|
|
|
if (!filter.CheckMessage(log_class, log_level)) {
|
|
|
|
if (!filter.CheckMessage(log_class, log_level)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
message_queue.EmplaceWait(
|
|
|
|
|
|
|
|
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message)));
|
|
|
|
auto entry =
|
|
|
|
|
|
|
|
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message));
|
|
|
|
|
|
|
|
if (Settings::values.log_async) {
|
|
|
|
|
|
|
|
message_queue.EmplaceWait(entry);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
std::scoped_lock l{sync_mutex};
|
|
|
|
|
|
|
|
ForEachBackend([&entry](Backend& backend) { backend.Write(entry); });
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
@ -313,6 +321,7 @@ private:
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
MPSCQueue<Entry> message_queue{};
|
|
|
|
MPSCQueue<Entry> message_queue{};
|
|
|
|
|
|
|
|
std::mutex sync_mutex;
|
|
|
|
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
|
|
|
|
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
|
|
|
|
std::jthread backend_thread;
|
|
|
|
std::jthread backend_thread;
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -345,9 +354,11 @@ void SetColorConsoleBackendEnabled(bool enabled) {
|
|
|
|
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
|
|
|
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
|
|
|
unsigned int line_num, const char* function, fmt::string_view format,
|
|
|
|
unsigned int line_num, const char* function, fmt::string_view format,
|
|
|
|
const fmt::format_args& args) {
|
|
|
|
const fmt::format_args& args) {
|
|
|
|
if (!initialization_in_progress_suppress_logging) {
|
|
|
|
if (initialization_in_progress_suppress_logging) {
|
|
|
|
Impl::Instance().PushEntry(log_class, log_level, filename, line_num, function,
|
|
|
|
return;
|
|
|
|
fmt::vformat(format, args));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Impl::Instance().PushEntry(log_class, log_level, filename, line_num, function,
|
|
|
|
|
|
|
|
fmt::vformat(format, args));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace Common::Log
|
|
|
|
} // namespace Common::Log
|
|
|
|