spdlog initialization. Add function to log fix
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "GameFixes.h"
|
||||
#include <memory>
|
||||
#include <filesystem>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/sinks/rotating_file_sink.h>
|
||||
#include <Windows.h>
|
||||
|
||||
inline std::shared_ptr<spdlog::logger> gLogger;
|
||||
|
||||
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,10 +23,34 @@ inline std::shared_ptr<spdlog::logger> InitializeLogger(const char* logger_name,
|
||||
logger->flush_on(spdlog::level::debug);
|
||||
|
||||
if (registerLog) spdlog::register_logger(logger);
|
||||
|
||||
gLogger = 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;
|
||||
}
|
||||
}
|
||||
|
||||
inline void LogFixToggle(GameFixes fix, bool fixEnabled) {
|
||||
if (fix == GameFixes::None) {
|
||||
if (gLogger) {
|
||||
if (fixEnabled) gLogger->info("Visual effects enabled individually");
|
||||
else gLogger->info("All visual effects disabled");
|
||||
}
|
||||
}
|
||||
|
||||
if (fix == GameFixes::DOF)
|
||||
if (gLogger) gLogger->info("Depth of field fix {}", fixEnabled ? "enabled" : "disabled");
|
||||
|
||||
if (fix == GameFixes::ChromaticAberrations)
|
||||
if (gLogger) gLogger->info("Chromatic aberrations fix {}", fixEnabled ? "enabled" : "disabled");
|
||||
|
||||
if (fix == GameFixes::Vignetting)
|
||||
if (gLogger) gLogger->info("Vignetting fix {}", fixEnabled ? "enabled" : "disabled");
|
||||
|
||||
if (fix == GameFixes::Fog)
|
||||
if (gLogger) gLogger->info("Fog fix {}", fixEnabled ? "enabled" : "disabled");
|
||||
}
|
||||
Reference in New Issue
Block a user