diff options
| author | Stefan Boberg <[email protected]> | 2023-11-13 10:44:43 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-13 10:44:43 +0100 |
| commit | afac06732afb7e326154cd96e19ed389408bb26d (patch) | |
| tree | bc45490febf972fd1bcccb946643bc24def63a37 /src | |
| parent | 0.2.31 (diff) | |
| download | zen-afac06732afb7e326154cd96e19ed389408bb26d.tar.xz zen-afac06732afb7e326154cd96e19ed389408bb26d.zip | |
fmt compilation fix for fmt v10+new vs build (#529)
VS 17.7.6 triggers some new compilation errors with certain versions of fmt::make_format_args. This should fix those errors. I don't fully understand why this is necessary, sadly my c++-fu is not strong enough.
Diffstat (limited to 'src')
| -rw-r--r-- | src/zencore/include/zencore/logging.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/zencore/include/zencore/logging.h b/src/zencore/include/zencore/logging.h index e3eb524e9..d14d1ab8d 100644 --- a/src/zencore/include/zencore/logging.h +++ b/src/zencore/include/zencore/logging.h @@ -61,6 +61,13 @@ void EmitLogMessage(LoggerRef& Logger, const SourceLocation& Location, int LogLe void EmitLogMessage(LoggerRef& Logger, int LogLevel, std::string_view Format, fmt::format_args Args); void EmitLogMessage(LoggerRef& Logger, const SourceLocation& Location, int LogLevel, std::string_view Format, fmt::format_args Args); +template<typename... T> +auto +LogCaptureArguments(T&&... Args) +{ + return fmt::make_format_args(Args...); +} + } // namespace zen::logging namespace zen { @@ -121,7 +128,7 @@ LogIsErrorLevel(int LogLevel) Location, \ InLevel, \ std::string_view(FormatString, sizeof FormatString - 1), \ - fmt::make_format_args(__VA_ARGS__)); \ + zen::logging::LogCaptureArguments(__VA_ARGS__)); \ } \ } while (false); @@ -137,7 +144,7 @@ LogIsErrorLevel(int LogLevel) zen::logging::EmitLogMessage(Logger, \ InLevel, \ std::string_view(FormatString, sizeof FormatString - 1), \ - fmt::make_format_args(__VA_ARGS__)); \ + zen::logging::LogCaptureArguments(__VA_ARGS__)); \ } \ } while (false); @@ -159,12 +166,12 @@ LogIsErrorLevel(int LogLevel) #define ZEN_ERROR(fmtstr, ...) ZEN_LOG_WITH_LOCATION(Log(), zen::logging::level::Err, fmtstr, ##__VA_ARGS__) #define ZEN_CRITICAL(fmtstr, ...) ZEN_LOG_WITH_LOCATION(Log(), zen::logging::level::Critical, fmtstr, ##__VA_ARGS__) -#define ZEN_CONSOLE_LOG(InLevel, fmtstr, ...) \ - do \ - { \ - using namespace std::literals; \ - ZEN_CHECK_FORMAT_STRING(fmtstr##sv, ##__VA_ARGS__); \ - zen::logging::EmitConsoleLogMessage(InLevel, fmtstr, fmt::make_format_args(__VA_ARGS__)); \ +#define ZEN_CONSOLE_LOG(InLevel, fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + ZEN_CHECK_FORMAT_STRING(fmtstr##sv, ##__VA_ARGS__); \ + zen::logging::EmitConsoleLogMessage(InLevel, fmtstr, zen::logging::LogCaptureArguments(__VA_ARGS__)); \ } while (false) #define ZEN_CONSOLE(fmtstr, ...) ZEN_CONSOLE_LOG(zen::logging::level::Info, fmtstr, ##__VA_ARGS__) |