#pragma once #ifndef MESSMER_CPPUTILS_LOGGING_LOGGING_H #define MESSMER_CPPUTILS_LOGGING_LOGGING_H #include "Logger.h" #include #include namespace cpputils { namespace logging { struct ERROR_TYPE {}; struct WARN_TYPE {}; struct INFO_TYPE {}; struct DEBUG_TYPE {}; constexpr ERROR_TYPE ERR {}; constexpr WARN_TYPE WARN {}; constexpr INFO_TYPE INFO {}; constexpr DEBUG_TYPE DEBUG {}; inline void setLogger(std::shared_ptr newLogger) { logger().setLogger(newLogger); } inline void reset() { logger().reset(); } inline void flush() { logger()->flush(); } inline void setLevel(ERROR_TYPE) { logger().setLevel(spdlog::level::err); } inline void setLevel(WARN_TYPE) { logger().setLevel(spdlog::level::warn); } inline void setLevel(INFO_TYPE) { logger().setLevel(spdlog::level::info); } inline void setLevel(DEBUG_TYPE) { logger().setLevel(spdlog::level::debug); } template inline void LOG(LogType logType, const std::string &msg) { LOG(logType, msg.c_str()); } template inline void LOG(ERROR_TYPE, const char* fmt, const Args&... args) { logger()->error(fmt, args...); } template inline void LOG(WARN_TYPE, const char* fmt, const Args&... args) { logger()->warn(fmt, args...); } template inline void LOG(INFO_TYPE, const char* fmt, const Args&... args) { logger()->info(fmt, args...); } template inline void LOG(DEBUG_TYPE, const char* fmt, const Args&... args) { logger()->debug(fmt, args...); } } } #endif