/********************************************************************* * \file Log.hpp * * \author Romain BOULLARD * \date February 2026 *********************************************************************/ #ifndef BIN2CPP_LOG_HPP #define BIN2CPP_LOG_HPP #include #include #include #ifdef BIN2CPP_WINDOWS #pragma warning(disable: 4702) #endif #include #include #include #include #include #if defined BIN2CPP_WINDOWS #pragma warning(default: 4702) #endif namespace Bin2CPP { class Log { public: Log(); Log(const Log& p_logger) = delete; Log(Log&& p_logger) = delete; /** * Register a logger. * * \return The logger, nullptr if it does not exist */ [[nodiscard]] quill::Logger* GetLogger(); /* * Flush all the loggers * */ void Flush(); ~Log(); Log& operator=(const Log& p_logger) = delete; Log& operator=(Log&& p_logger) = delete; private: /* * The sinks */ eastl::array, 1> m_sinks; }; } // namespace Bin2CPP #define BIN2CPP_LOG_DEBUG(fmt, ...) \ do \ { \ if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ { \ QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ } \ } while (0) #define BIN2CPP_LOG_TRACE(fmt, ...) \ do \ { \ if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ { \ QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ } \ } while (0) #define BIN2CPP_LOG_INFO(fmt, ...) \ do \ { \ if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ { \ QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ } \ } while (0) #define BIN2CPP_LOG_WARN(fmt, ...) \ do \ { \ if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ { \ QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ } \ } while (0) #define BIN2CPP_LOG_ERROR(fmt, ...) \ do \ { \ if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ { \ QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ } \ } while (0) #define BIN2CPP_LOG_FATAL(fmt, ...) \ do \ { \ if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ { \ QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ } \ } while (0) #endif