|
|
@ -39,8 +39,10 @@ public:
|
|
|
|
Impl(Impl const&) = delete;
|
|
|
|
Impl(Impl const&) = delete;
|
|
|
|
const Impl& operator=(Impl const&) = delete;
|
|
|
|
const Impl& operator=(Impl const&) = delete;
|
|
|
|
|
|
|
|
|
|
|
|
void PushEntry(Entry e) {
|
|
|
|
void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
|
|
|
|
message_queue.Push(std::move(e));
|
|
|
|
const char* function, std::string message) {
|
|
|
|
|
|
|
|
message_queue.Push(
|
|
|
|
|
|
|
|
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AddBackend(std::unique_ptr<Backend> backend) {
|
|
|
|
void AddBackend(std::unique_ptr<Backend> backend) {
|
|
|
@ -108,6 +110,26 @@ private:
|
|
|
|
backend_thread.join();
|
|
|
|
backend_thread.join();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
|
|
|
|
|
|
|
|
const char* function, std::string message) const {
|
|
|
|
|
|
|
|
using std::chrono::duration_cast;
|
|
|
|
|
|
|
|
using std::chrono::steady_clock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static steady_clock::time_point time_origin = steady_clock::now();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Entry entry;
|
|
|
|
|
|
|
|
entry.timestamp =
|
|
|
|
|
|
|
|
duration_cast<std::chrono::microseconds>(steady_clock::now() - time_origin);
|
|
|
|
|
|
|
|
entry.log_class = log_class;
|
|
|
|
|
|
|
|
entry.log_level = log_level;
|
|
|
|
|
|
|
|
entry.filename = Common::TrimSourcePath(filename);
|
|
|
|
|
|
|
|
entry.line_num = line_nr;
|
|
|
|
|
|
|
|
entry.function = function;
|
|
|
|
|
|
|
|
entry.message = std::move(message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::mutex writing_mutex;
|
|
|
|
std::mutex writing_mutex;
|
|
|
|
std::thread backend_thread;
|
|
|
|
std::thread backend_thread;
|
|
|
|
std::vector<std::unique_ptr<Backend>> backends;
|
|
|
|
std::vector<std::unique_ptr<Backend>> backends;
|
|
|
@ -271,25 +293,6 @@ const char* GetLevelName(Level log_level) {
|
|
|
|
#undef LVL
|
|
|
|
#undef LVL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
|
|
|
|
|
|
|
|
const char* function, std::string message) {
|
|
|
|
|
|
|
|
using std::chrono::duration_cast;
|
|
|
|
|
|
|
|
using std::chrono::steady_clock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static steady_clock::time_point time_origin = steady_clock::now();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Entry entry;
|
|
|
|
|
|
|
|
entry.timestamp = duration_cast<std::chrono::microseconds>(steady_clock::now() - time_origin);
|
|
|
|
|
|
|
|
entry.log_class = log_class;
|
|
|
|
|
|
|
|
entry.log_level = log_level;
|
|
|
|
|
|
|
|
entry.filename = Common::TrimSourcePath(filename);
|
|
|
|
|
|
|
|
entry.line_num = line_nr;
|
|
|
|
|
|
|
|
entry.function = function;
|
|
|
|
|
|
|
|
entry.message = std::move(message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SetGlobalFilter(const Filter& filter) {
|
|
|
|
void SetGlobalFilter(const Filter& filter) {
|
|
|
|
Impl::Instance().SetGlobalFilter(filter);
|
|
|
|
Impl::Instance().SetGlobalFilter(filter);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -314,9 +317,7 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
|
|
|
|
if (!filter.CheckMessage(log_class, log_level))
|
|
|
|
if (!filter.CheckMessage(log_class, log_level))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
Entry entry =
|
|
|
|
instance.PushEntry(log_class, log_level, filename, line_num, function,
|
|
|
|
CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args));
|
|
|
|
fmt::vformat(format, args));
|
|
|
|
|
|
|
|
|
|
|
|
instance.PushEntry(std::move(entry));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace Log
|
|
|
|
} // namespace Log
|
|
|
|