From 42f653ab6fc8ab07ba0db4ffb4d2b0267115a588 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sat, 8 Jan 2022 01:48:53 -0700 Subject: logging: adapt to changes in fmt 8.1 --- src/common/logging/log.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/logging/log.h b/src/common/logging/log.h index c186d55ef..b6a14972f 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -6,11 +6,24 @@ #include #include +#include -#include +#include #include "common/logging/types.h" +// adapted from https://github.com/fmtlib/fmt/issues/2704 +// a generic formatter for enum classes (<= 32 bits) +#if FMT_VERSION >= 80100 +template +struct fmt::formatter, char>> : formatter { + template + auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { + return fmt::formatter::format(static_cast(value), ctx); + } +}; +#endif + namespace Common::Log { // trims up to and including the last of ../, ..\, src/, src\ in a string -- cgit v1.2.3 From 099dd0c0d299d0f3541221928814e9001a69623a Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sat, 8 Jan 2022 16:02:49 -0700 Subject: logging/log: use `underlying_type` instead of hardcoding types --- src/common/logging/log.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/logging/log.h b/src/common/logging/log.h index b6a14972f..096a441b8 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -16,10 +16,12 @@ // a generic formatter for enum classes (<= 32 bits) #if FMT_VERSION >= 80100 template -struct fmt::formatter, char>> : formatter { +struct fmt::formatter, char>> + : formatter> { template auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { - return fmt::formatter::format(static_cast(value), ctx); + return fmt::formatter>::format( + static_cast>(value), ctx); } }; #endif -- cgit v1.2.3 From 09f4f3f23b5181883c7423a171edd5ec6467df02 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sat, 8 Jan 2022 21:42:11 -0700 Subject: logging/log.h: move enum class formatter to a separate file ... ... to common/logging/formatter.h --- src/common/CMakeLists.txt | 1 + src/common/logging/formatter.h | 23 +++++++++++++++++++++++ src/common/logging/log.h | 16 +--------------- 3 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 src/common/logging/formatter.h (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 790193b00..adf70eb8b 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -85,6 +85,7 @@ add_library(common STATIC logging/backend.h logging/filter.cpp logging/filter.h + logging/formatter.h logging/log.h logging/log_entry.h logging/text_formatter.cpp diff --git a/src/common/logging/formatter.h b/src/common/logging/formatter.h new file mode 100644 index 000000000..552cde75a --- /dev/null +++ b/src/common/logging/formatter.h @@ -0,0 +1,23 @@ +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include + +#include + +// adapted from https://github.com/fmtlib/fmt/issues/2704 +// a generic formatter for enum classes +#if FMT_VERSION >= 80100 +template +struct fmt::formatter, char>> + : formatter> { + template + auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { + return fmt::formatter>::format( + static_cast>(value), ctx); + } +}; +#endif diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 096a441b8..0c80d01ee 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -6,26 +6,12 @@ #include #include -#include #include +#include "common/logging/formatter.h" #include "common/logging/types.h" -// adapted from https://github.com/fmtlib/fmt/issues/2704 -// a generic formatter for enum classes (<= 32 bits) -#if FMT_VERSION >= 80100 -template -struct fmt::formatter, char>> - : formatter> { - template - auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { - return fmt::formatter>::format( - static_cast>(value), ctx); - } -}; -#endif - namespace Common::Log { // trims up to and including the last of ../, ..\, src/, src\ in a string -- cgit v1.2.3