From ddbc24af6a1e7e1b37d6b132d76b9e3ed046b4d7 Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Sun, 1 Feb 2026 20:40:18 +0100 Subject: [PATCH] Add spdlog lib --- libs/Logger/Logger.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 libs/Logger/Logger.hpp diff --git a/libs/Logger/Logger.hpp b/libs/Logger/Logger.hpp new file mode 100644 index 0000000..e696fe0 --- /dev/null +++ b/libs/Logger/Logger.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include +#include +#include +#include +#include + +inline std::shared_ptr InitializeLogger(const char* logger_name, const std::string& pluginLog) { + try { + std::filesystem::path log_path = std::filesystem::absolute(pluginLog); + + if (std::filesystem::exists(log_path)) + std::filesystem::remove(log_path); + + auto logger = std::make_shared(logger_name,std::make_shared( + pluginLog, 10 * 1024 * 1024,1)); + + logger->set_level(spdlog::level::debug); + logger->flush_on(spdlog::level::debug); + + spdlog::register_logger(logger); + return logger; + } + catch (const spdlog::spdlog_ex&) { + MessageBoxA(nullptr,("Could not open " + std::string(pluginLog)).c_str(),"Logger Error",MB_ICONERROR | MB_OK); + return nullptr; + } +} \ No newline at end of file