diff --git a/include/zenkit/Logger.hh b/include/zenkit/Logger.hh index 7a4c92dc..f7e8793b 100644 --- a/include/zenkit/Logger.hh +++ b/include/zenkit/Logger.hh @@ -3,6 +3,7 @@ #pragma once #include "zenkit/Library.hh" +#include #include #include #include @@ -40,6 +41,7 @@ namespace zenkit { ZKREM("renamed to ::set_default") ZKAPI static void use_default_logger(); ZK_PRINTF_LIKE(3, 4) ZKAPI static void log(LogLevel lvl, char const* name, char const* fmt, ...); + ZKAPI static void logv(LogLevel lvl, char const* name, char const* fmt, va_list ap); ZKAPI static void set(LogLevel lvl, std::function const& cb); ZKAPI static void set_default(LogLevel lvl); diff --git a/src/Logger.cc b/src/Logger.cc index 4b827404..1ed9afdd 100644 --- a/src/Logger.cc +++ b/src/Logger.cc @@ -66,14 +66,16 @@ namespace zenkit { } void Logger::log(LogLevel lvl, char const* name, char const* fmt, ...) { - if (!_s_callback) return; - if (lvl > _s_level) return; - va_list ap; va_start(ap, fmt); - vsnprintf(zk_global_logger_buffer, sizeof zk_global_logger_buffer - 1, fmt, ap); + logv(lvl, name, fmt, ap); va_end(ap); + } + void Logger::logv(LogLevel lvl, char const* name, char const* fmt, va_list ap) { + if (!_s_callback) return; + if (lvl > _s_level) return; + vsnprintf(zk_global_logger_buffer, sizeof zk_global_logger_buffer - 1, fmt, ap); _s_callback(lvl, name, zk_global_logger_buffer); }