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 <>
struct fmt::formatter<std::u8string_view> : formatter<string_view> {
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());
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
template <typename T>
auto ForwardEnum(T t) {
auto ForwardEnum(T t)
{
if constexpr (std::is_enum_v<T>)
return fmt::underlying(t);
else
@ -61,21 +63,22 @@ auto ForwardEnum(T t) {
}
template <typename... TArgs>
auto ForwardEnum(std::tuple<TArgs...> t) {
return std::apply([](auto... x) { return std::make_tuple(ForwardEnum(x)...); }, t);
auto ForwardEnum(std::tuple<TArgs...> t)
{
return std::apply([](auto... x) { return std::make_tuple(ForwardEnum(x)...); }, t);
}
template<typename T, typename ... TArgs>
bool cemuLog_log(LogType type, std::basic_string<T> format, TArgs&&... args)
{
if (!cemuLog_isLoggingEnabled(type))
return false;
{
if (!cemuLog_isLoggingEnabled(type))
return false;
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)...));
cemuLog_log(type, std::basic_string_view(text.data(), text.size()));
return true;
}
cemuLog_log(type, std::basic_string_view(text.data(), text.size()));
return true;
}
template<typename T, typename ... TArgs>
bool cemuLog_log(LogType type, const T* format, TArgs&&... args)