From 83fb234d5c1fbf827cb6edcd6a64c42293e1b165 Mon Sep 17 00:00:00 2001 From: T0b1 Date: Sun, 25 Jun 2023 03:19:42 +0200 Subject: [PATCH] spdlog :D --- CMakeLists.txt | 11 ++++++++++- src/backend/lldb/lldb_backend.cpp | 11 ++++++----- src/main.cpp | 8 ++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce61185..aeca09d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,14 @@ find_package(OpenGL REQUIRED) # TODO: build glfw ourselved so that we can link it statically find_package(glfw3 REQUIRED) +Include(FetchContent) +FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.11.0 +) +FetchContent_MakeAvailable(spdlog) + include_directories(${LLVM_INCLUDE_DIRS}) include_directories(${OPENGL_INCLUDE_DIR}) include_directories(deps/imgui/) @@ -38,4 +46,5 @@ set(DBGUI_SOURCES add_executable(dbgui ${DBGUI_SOURCES}) target_link_libraries(dbgui ${OPENGL_LIBRARIES} glfw) -target_link_libraries(dbgui lldb) \ No newline at end of file +target_link_libraries(dbgui lldb) +target_link_libraries(dbgui spdlog::spdlog) \ No newline at end of file diff --git a/src/backend/lldb/lldb_backend.cpp b/src/backend/lldb/lldb_backend.cpp index f9d2be0..2dd6097 100644 --- a/src/backend/lldb/lldb_backend.cpp +++ b/src/backend/lldb/lldb_backend.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -93,15 +94,15 @@ void LLDBBackend::wait_for_debug_events() if (listener.WaitForEvent(0xFFFFFFFF, event)) { std::lock_guard g{_data_lock}; - printf("Got Event:\n"); + spdlog::info("Got Event"); auto stream = lldb::SBStream{}; if (event.GetDescription(stream)) { - printf(" Desc: %.*s\n", static_cast(stream.GetSize()), - stream.GetData()); + spdlog::info(" -> Desc: {}", + std::string_view{stream.GetData(), stream.GetSize()}); } else { - printf(" Failed to get stream\n"); + spdlog::warn(" -> Failed to get stream\n"); } if (SBProcess::EventIsProcessEvent(event)) @@ -115,7 +116,7 @@ void LLDBBackend::wait_for_debug_events() } } else { - printf(" Unknown event source!\n"); + spdlog::warn(" -> Unknown event source!\n"); } } } diff --git a/src/main.cpp b/src/main.cpp index e2a0ac4..b290033 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,8 @@ #define GL_SILENCE_DEPRECATION #include // Will drag system OpenGL headers #include +#include +#include #include "frontend/frontend.h" @@ -24,8 +26,14 @@ static void glfw_error_callback(int error, const char *description) // Main code int main(int, char **) { + spdlog::cfg::load_env_levels(); pthread_setname_np(pthread_self(), "render_thread"); + spdlog::info("Welcome to spdlog version {}.{}.{} !", SPDLOG_VER_MAJOR, + SPDLOG_VER_MINOR, SPDLOG_VER_PATCH); + + spdlog::info("Starting dbgui..."); + glfwSetErrorCallback(glfw_error_callback); if (!glfwInit()) return 1;