From 05aa96d20ca726908a7d8b1943f86f0c4e11bf18 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Wed, 17 Jun 2026 01:46:09 -0500 Subject: Prepare Nexus-safe release cleanup --- libs/installer_fomod_plus/installer/lib/Logger.h | 116 ----------------------- 1 file changed, 116 deletions(-) delete mode 100644 libs/installer_fomod_plus/installer/lib/Logger.h (limited to 'libs/installer_fomod_plus/installer/lib/Logger.h') diff --git a/libs/installer_fomod_plus/installer/lib/Logger.h b/libs/installer_fomod_plus/installer/lib/Logger.h deleted file mode 100644 index 53fb7d9..0000000 --- a/libs/installer_fomod_plus/installer/lib/Logger.h +++ /dev/null @@ -1,116 +0,0 @@ -#pragma once -#include -#include -#include -#include - - -// Log levels -enum LogLevel { - DEBUG = 0, - INFO = 1, - WARN = 2, - ERR = 3 -}; - -// Convert LogLevel to string -inline const char* logLevelToString(const LogLevel level) { - switch (level) { - case DEBUG: return "DEBUG"; - case INFO: return "INFO"; - case WARN: return "WARN"; - case ERR: return "ERROR"; - default: return "UNKNOWN"; - } -} - - -class Logger { -public: - static Logger& getInstance() - { - static Logger instance; - return instance; - } - - void setLogFilePath(const std::string& filePath) - { - std::lock_guard lock(mMutex); - if (mLogFile.is_open()) { - mLogFile.close(); - } - mLogFile.open(filePath, std::ios::out); - // std::ios::app is an option for appending but dont wanna grow it forever. - } - - void setDebugMode(bool debug) - { - std::lock_guard lock(mMutex); - mDebugMode = debug; - } - - void logMessage(const LogLevel level, const std::string& message) - { - -#if defined(__GNUC__) || defined(__clang__) - std::string functionName = __PRETTY_FUNCTION__; -#elif defined(_MSC_VER) - std::string functionName = __FUNCSIG__; -#else - std::string functionName = "UnknownFunction"; -#endif - - std::regex classNameRegex(R"((\w+)::\w+\()"); - std::smatch match; - std::string className = "UnknownClass"; - - if (std::regex_search(functionName, match, classNameRegex) && match.size() > 1) { - className = match.str(1); - } - - std::lock_guard lock(mMutex); - - auto writeLog = [&](std::ostream& stream) { - switch (level) { - case DEBUG: - stream << "[DEBUG] " << message << std::endl; - break; - case INFO: - stream << "[INFO] " << message << std::endl; - break; - case WARN: - stream << "[WARN] " << message << std::endl; - break; - case ERR: - stream << "[ERROR] " << message << std::endl; - break; - } - }; - - if (mLogFile.is_open()) { - writeLog(mLogFile); - } - } - - Logger& operator=(const Logger&) = delete; - -private: - Logger() = default; - - ~Logger() - { - if (mLogFile.is_open()) { - mLogFile.close(); - } - } - - Logger(const Logger&) = delete; - - std::ofstream mLogFile; - std::mutex mMutex; -#if !defined(NDEBUG) || defined(CMAKE_BUILD_TYPE_RELWITHDEBINFO) - bool mDebugMode = true; // Auto-enable in debug/RelWithDebInfo builds -#else - bool mDebugMode = false; // Disable in release builds -#endif -}; \ No newline at end of file -- cgit v1.3.1