spdlog implementation (#58)

* Commit new spdlog implementation 

Hopefully resolves Linux build dependency errors

* clang formatting

* Fix Linux-only definition

Found the culprit!

* More Linux fixes

Linus Torvalds have mercy on my soul

* Replace printf logging with spdlog equivalent

Preserve previous printfs in comments for now. Spdlog needs to be configured to be thread-safe. Few additional printfs to convert later. No changes have been made to GOAL's internal printing system

* clang-format stuff

* ugh more clang-format

why

* Another shot

* CMakeLists.txt update

Fix issues related to spdlog version targeting

* Remove old prints + fix log types

Up next is the transition to a git submodule, should be simple enough

* spdlog is now a git submodule

* adapted for project

* Linux fix

* More fixes

Yikes

* Update for linux

I should really fix my WSL environment

* Update workflow.yaml

Hopefully will resolve issues with GitHub Actions on Linux
This commit is contained in:
doctashay
2020-10-03 07:39:04 -06:00
committed by GitHub
parent 376c273845
commit c2cb053a5d
169 changed files with 41646 additions and 69 deletions
+9 -6
View File
@@ -3,6 +3,7 @@
#endif
#include "SystemThread.h"
#include "third-party/spdlog/include/spdlog/spdlog.h"
//////////////////////
// Thread Manager //
@@ -13,7 +14,8 @@
*/
SystemThread& SystemThreadManager::create_thread(const std::string& name) {
if (thread_count >= MAX_SYSTEM_THREADS) {
throw std::runtime_error("Out of System Threads! Please increase MAX_SYSTEM_THREADS");
spdlog::critical("Out of System Threads! MAX_SYSTEM_THREADS is ", MAX_SYSTEM_THREADS);
throw std::runtime_error("Out of System Threads! Please increase MAX_SYSTEM_THREADS");
}
auto& thread = threads[thread_count];
@@ -49,7 +51,7 @@ void SystemThreadManager::print_stats() {
*/
void SystemThreadManager::shutdown() {
for (int i = 0; i < thread_count; i++) {
printf("# Stop %s\n", threads[i].name.c_str());
spdlog::debug("# Stop {}", threads[i].name.c_str());
threads[i].stop();
}
}
@@ -59,7 +61,7 @@ void SystemThreadManager::shutdown() {
*/
void SystemThreadManager::join() {
for (int i = 0; i < thread_count; i++) {
printf("# Join %s\n", threads[i].name.c_str());
spdlog::debug(" # Join {}", threads[i].name.c_str());
if (threads[i].running) {
threads[i].join();
}
@@ -73,7 +75,7 @@ void* bootstrap_thread_func(void* x) {
SystemThread* thd = (SystemThread*)x;
SystemThreadInterface iface(thd);
thd->function(iface);
printf("[SYSTEM] Thread %s is returning\n", thd->name.c_str());
spdlog::debug("[SYSTEM] Thread {} is returning", thd->name.c_str());
return nullptr;
}
@@ -81,7 +83,8 @@ void* bootstrap_thread_func(void* x) {
* Start a thread and wait for its initialization
*/
void SystemThread::start(std::function<void(SystemThreadInterface&)> f) {
printf("# Initialize %s...\n", name.c_str());
spdlog::debug("# Initialize {}...", name.c_str());
function = f;
thread = std::thread(bootstrap_thread_func, this);
running = true;
@@ -118,7 +121,7 @@ void SystemThreadInterface::initialization_complete() {
std::unique_lock<std::mutex> mlk(thread.initialization_mutex);
thread.initialization_complete = true;
thread.initialization_cv.notify_all();
printf("# %s initialized\n", thread.name.c_str());
spdlog::debug("# {} initialized", thread.name.c_str());
}
/*!