core: Rewrite thread local storage implementation (#118)

This commit is contained in:
TheTurtle 2024-05-01 13:38:41 +03:00 committed by GitHub
parent b94efcba5a
commit 1b9bf924ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 176 additions and 189 deletions

View file

@ -175,28 +175,18 @@ public:
using std::chrono::microseconds;
using std::chrono::steady_clock;
const Entry entry = {
.timestamp = duration_cast<microseconds>(steady_clock::now() - time_origin),
.log_class = log_class,
.log_level = log_level,
.filename = filename,
.line_num = line_num,
.function = function,
.message = std::move(message),
};
if (Config::getLogType() == "async") {
message_queue.EmplaceWait(Entry{
.timestamp = duration_cast<microseconds>(steady_clock::now() - time_origin),
.log_class = log_class,
.log_level = log_level,
.filename = filename,
.line_num = line_num,
.function = function,
.message = std::move(message),
});
message_queue.EmplaceWait(entry);
} else {
const Entry entry = {
.timestamp = duration_cast<microseconds>(steady_clock::now() - time_origin),
.log_class = log_class,
.log_level = log_level,
.filename = filename,
.line_num = line_num,
.function = function,
.message = std::move(message),
};
ForEachBackend([&entry](auto& backend) { backend.Write(entry); });
}
}
@ -239,7 +229,7 @@ private:
}
void ForEachBackend(auto lambda) {
lambda(debugger_backend);
// lambda(debugger_backend);
lambda(color_console_backend);
lambda(file_backend);
}