#pragma once #include #include // TODO: Use std::format_string when available #include #include #include namespace kuiper { class logger { public: logger() : m_log(spdlog::stdout_color_st("log")) { #if !defined(NDEBUG) m_log->set_level(spdlog::level::debug); #else m_log->set_level(spdlog::level::info); #endif } logger(const char* name) : m_log(spdlog::stdout_color_st(name)) { #if !defined(NDEBUG) m_log->set_level(spdlog::level::debug); #else m_log->set_level(spdlog::level::info); #endif } ~logger() = default; template inline void trace(std::string_view fmt, Args&&... args) { m_log->trace(fmt, std::forward(args)...); } template inline void debug(std::string_view fmt, Args&&... args) { m_log->debug(fmt, std::forward(args)...); } template inline void info(std::string_view fmt, Args&&... args) { m_log->info(fmt, std::forward(args)...); } template inline void warn(std::string_view fmt, Args&&... args) { m_log->warn(fmt, std::forward(args)...); } template inline void error(std::string_view fmt, Args&&... args) { m_log->error(fmt, std::forward(args)...); } template inline void critical(std::string_view fmt, Args&&... args) { m_log->critical(fmt, std::forward(args)...); } private: std::shared_ptr m_log {nullptr}; }; } // namespace kuiper