Add the ability to register or not spdlog to prevent crash

This commit is contained in:
2026-03-12 14:58:47 +01:00
parent cd349e7d38
commit 377e287ef2

View File

@@ -5,8 +5,7 @@
#include <spdlog/spdlog.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <Windows.h>
inline std::shared_ptr<spdlog::logger> InitializeLogger(const char* logger_name, const std::string& pluginLog) {
inline std::shared_ptr<spdlog::logger> InitializeLogger(const char* logger_name, const std::string& pluginLog, bool registerLog = true) {
try {
std::filesystem::path log_path = std::filesystem::absolute(pluginLog);
@@ -19,7 +18,7 @@ inline std::shared_ptr<spdlog::logger> InitializeLogger(const char* logger_name,
logger->set_level(spdlog::level::debug);
logger->flush_on(spdlog::level::debug);
spdlog::register_logger(logger);
if (registerLog) spdlog::register_logger(logger);
return logger;
}
catch (const spdlog::spdlog_ex&) {