diff --git a/cpp/include/raft/core/logger-ext.hpp b/cpp/include/raft/core/logger-ext.hpp index 69688560c7..8fd29cf1d6 100644 --- a/cpp/include/raft/core/logger-ext.hpp +++ b/cpp/include/raft/core/logger-ext.hpp @@ -15,15 +15,19 @@ */ #pragma once -#include // std::unique_ptr -#include // std::string -#include // std::unordered_map +#include // std::unique_ptr +#include // RAFT_INLINE_CONDITIONAL +#include // std::string +#include // std::unordered_map namespace raft { static const std::string RAFT_NAME = "raft"; static const std::string default_log_pattern("[%L] [%H:%M:%S.%f] %v"); +namespace detail { +RAFT_INLINE_CONDITIONAL std::string format(const char* fmt, ...); +} /** * @brief The main Logging class for raft library. * diff --git a/cpp/include/raft/core/logger-inl.hpp b/cpp/include/raft/core/logger-inl.hpp index a90023d01f..fcfa1f1333 100644 --- a/cpp/include/raft/core/logger-inl.hpp +++ b/cpp/include/raft/core/logger-inl.hpp @@ -54,7 +54,7 @@ inline std::string format(const char* fmt, va_list& vl) return std::string(buf.data()); } -inline std::string format(const char* fmt, ...) +RAFT_INLINE_CONDITIONAL std::string format(const char* fmt, ...) { va_list vl; va_start(vl, fmt); diff --git a/cpp/test/core/logger.cpp b/cpp/test/core/logger.cpp index 3f29c9f12c..d7f001a700 100644 --- a/cpp/test/core/logger.cpp +++ b/cpp/test/core/logger.cpp @@ -14,6 +14,11 @@ * limitations under the License. */ +// We set RAFT_ACTIVE_LEVEL to a value that would enable testing trace and debug logs +// (otherwise trace and debug logs are desabled by default). +#undef RAFT_ACTIVE_LEVEL +#define RAFT_ACTIVE_LEVEL 6 + #include #include #include