spdlog :D

This commit is contained in:
T0b1
2023-06-25 03:19:42 +02:00
parent 10826ff2d5
commit 83fb234d5c
3 changed files with 24 additions and 6 deletions

View File

@@ -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)
target_link_libraries(dbgui lldb)
target_link_libraries(dbgui spdlog::spdlog)

View File

@@ -19,6 +19,7 @@
#include <cassert>
#include <cstring>
#include <algorithm>
#include <spdlog/spdlog.h>
#include <pthread.h>
@@ -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<int>(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");
}
}
}

View File

@@ -13,6 +13,8 @@
#define GL_SILENCE_DEPRECATION
#include <GLFW/glfw3.h> // Will drag system OpenGL headers
#include <pthread.h>
#include <spdlog/spdlog.h>
#include <spdlog/cfg/env.h>
#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;