Use the same formatting style as the rest of the code base

This commit is contained in:
ssimco 2022-09-04 21:00:58 +03:00
parent d9f3a0f4e6
commit 9c067b07a9

View file

@ -36,7 +36,8 @@ enum class LogType : sint32
template <> template <>
struct fmt::formatter<std::u8string_view> : formatter<string_view> { struct fmt::formatter<std::u8string_view> : formatter<string_view> {
template <typename FormatContext> template <typename FormatContext>
auto format(std::u8string_view v, FormatContext& ctx) { auto format(std::u8string_view v, FormatContext& ctx)
{
string_view s((char*)v.data(), v.size()); string_view s((char*)v.data(), v.size());
return formatter<string_view>::format(s, ctx); return formatter<string_view>::format(s, ctx);
} }
@ -53,7 +54,8 @@ bool cemuLog_log(LogType type, std::wstring_view text);
void cemuLog_waitForFlush(); // wait until all log lines are written void cemuLog_waitForFlush(); // wait until all log lines are written
template <typename T> template <typename T>
auto ForwardEnum(T t) { auto ForwardEnum(T t)
{
if constexpr (std::is_enum_v<T>) if constexpr (std::is_enum_v<T>)
return fmt::underlying(t); return fmt::underlying(t);
else else
@ -61,21 +63,22 @@ auto ForwardEnum(T t) {
} }
template <typename... TArgs> template <typename... TArgs>
auto ForwardEnum(std::tuple<TArgs...> t) { auto ForwardEnum(std::tuple<TArgs...> t)
return std::apply([](auto... x) { return std::make_tuple(ForwardEnum(x)...); }, t); {
return std::apply([](auto... x) { return std::make_tuple(ForwardEnum(x)...); }, t);
} }
template<typename T, typename ... TArgs> template<typename T, typename ... TArgs>
bool cemuLog_log(LogType type, std::basic_string<T> format, TArgs&&... args) bool cemuLog_log(LogType type, std::basic_string<T> format, TArgs&&... args)
{ {
if (!cemuLog_isLoggingEnabled(type)) if (!cemuLog_isLoggingEnabled(type))
return false; return false;
const auto format_view = fmt::basic_string_view<T>(format); const auto format_view = fmt::basic_string_view<T>(format);
const auto text = fmt::vformat(format_view, fmt::make_format_args<fmt::buffer_context<T>>(ForwardEnum(args)...)); const auto text = fmt::vformat(format_view, fmt::make_format_args<fmt::buffer_context<T>>(ForwardEnum(args)...));
cemuLog_log(type, std::basic_string_view(text.data(), text.size())); cemuLog_log(type, std::basic_string_view(text.data(), text.size()));
return true; return true;
} }
template<typename T, typename ... TArgs> template<typename T, typename ... TArgs>
bool cemuLog_log(LogType type, const T* format, TArgs&&... args) bool cemuLog_log(LogType type, const T* format, TArgs&&... args)