logging: implement std::formatter for some types (#3380)

This commit is contained in:
memchr
2023-09-20 15:25:03 +00:00
committed by GitHub
parent 6594b50e57
commit 3785defaf1
20 changed files with 217 additions and 96 deletions

View File

@@ -1,7 +1,5 @@
#pragma once
#include "helpers/MiscFunctions.hpp"
#include "debug/Log.hpp"
#include <cmath>
#include <csignal>
#include <utility>
@@ -66,6 +64,32 @@
#define ASSERT(expr) RASSERT(expr, "?")
// absolutely ridiculous formatter spec parsing
#define FORMAT_PARSE(specs__, type__) \
template <typename FormatContext> \
constexpr auto parse(FormatContext& ctx) { \
auto it = ctx.begin(); \
for (; it != ctx.end() && *it != '}'; it++) { \
switch (*it) { specs__ default : throw std::format_error("invalid format specification"); } \
} \
return it; \
}
#define FORMAT_FLAG(spec__, flag__) \
case spec__: (flag__) = true; break;
#define FORMAT_NUMBER(buf__) \
case '0': \
case '1': \
case '2': \
case '3': \
case '4': \
case '5': \
case '6': \
case '7': \
case '8': \
case '9': (buf__).push_back(*it); break;
#if ISDEBUG
#define UNREACHABLE() \
{ \