From 396e22b3488cda4bea93f3afa7233fe239699d35 Mon Sep 17 00:00:00 2001 From: Adam Macdonald Date: Wed, 7 May 2025 14:01:17 +0100 Subject: [PATCH] fix format string when building with newer versions of libstdc++ --- include/logging/engine_logger.hpp | 27 +++++++++++++++------------ include/logging/logger.hpp | 14 +++++++------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/logging/engine_logger.hpp b/include/logging/engine_logger.hpp index 1a58cf4..aad6081 100644 --- a/include/logging/engine_logger.hpp +++ b/include/logging/engine_logger.hpp @@ -2,6 +2,9 @@ #include "logging/logger.hpp" +#include +#include + namespace kuiper { @@ -20,33 +23,33 @@ class engine_logger { } template - inline void trace(const char* fmt, Args... args) { - m_log.trace(fmt, args...); + inline void trace(std::format_string fmt, Args... args) { + m_log.trace(fmt, std::forward(args)...); } template - inline void debug(const char* fmt, Args... args) { - m_log.debug(fmt, args...); + inline void debug(std::format_string fmt, Args... args) { + m_log.debug(fmt, std::forward(args)...); } template - inline void info(const char* fmt, Args... args) { - m_log.info(fmt, args...); + inline void info(std::format_string fmt, Args... args) { + m_log.info(fmt, std::forward(args)...); } template - inline void warn(const char* fmt, Args... args) { - m_log.warn(fmt, args...); + inline void warn(std::format_string fmt, Args... args) { + m_log.warn(fmt, std::forward(args)...); } template - inline void error(const char* fmt, Args... args) { - m_log.error(fmt, args...); + inline void error(std::format_string fmt, Args... args) { + m_log.error(fmt, std::forward(args)...); } template - inline void critical(const char* fmt, Args... args) { - m_log.critical(fmt, args...); + inline void critical(std::format_string fmt, Args... args) { + m_log.critical(fmt, std::forward(args)...); } private: diff --git a/include/logging/logger.hpp b/include/logging/logger.hpp index 348cec5..bdd3483 100644 --- a/include/logging/logger.hpp +++ b/include/logging/logger.hpp @@ -1,7 +1,7 @@ #pragma once +#include #include -#include // TODO: Use std::format_string when available #include #include @@ -31,32 +31,32 @@ class logger { ~logger() = default; template - inline void trace(std::string_view fmt, Args&&... args) { + inline void trace(std::format_string fmt, Args&&... args) { m_log->trace(fmt, std::forward(args)...); } template - inline void debug(std::string_view fmt, Args&&... args) { + inline void debug(std::format_string fmt, Args&&... args) { m_log->debug(fmt, std::forward(args)...); } template - inline void info(std::string_view fmt, Args&&... args) { + inline void info(std::format_string fmt, Args&&... args) { m_log->info(fmt, std::forward(args)...); } template - inline void warn(std::string_view fmt, Args&&... args) { + inline void warn(std::format_string fmt, Args&&... args) { m_log->warn(fmt, std::forward(args)...); } template - inline void error(std::string_view fmt, Args&&... args) { + inline void error(std::format_string fmt, Args&&... args) { m_log->error(fmt, std::forward(args)...); } template - inline void critical(std::string_view fmt, Args&&... args) { + inline void critical(std::format_string fmt, Args&&... args) { m_log->critical(fmt, std::forward(args)...); }