mirror of https://github.com/AxioDL/logvisor.git
Update fmtlib
This commit is contained in:
parent
27814c5276
commit
d62b4ce26e
2
fmt
2
fmt
|
@ -1 +1 @@
|
||||||
Subproject commit 25ff2efc0aeab3ce886fb6be11a1878f3497ec4c
|
Subproject commit 9bdd1596cef1b57b9556f8bef32dc4a32322ef3e
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#define FMT_STRING_ALIAS 1
|
#define FMT_STRING_ALIAS 1
|
||||||
#define FMT_ENFORCE_COMPILE_STRING 1
|
#define FMT_ENFORCE_COMPILE_STRING 1
|
||||||
#define FMT_USE_GRISU 0
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
|
@ -264,7 +263,7 @@ struct formatter<tp, char> { \
|
||||||
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \
|
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \
|
||||||
template <typename FormatContext> \
|
template <typename FormatContext> \
|
||||||
auto format(const tp &obj, FormatContext &ctx) { \
|
auto format(const tp &obj, FormatContext &ctx) { \
|
||||||
return format_to(ctx.out(), fmt(fmtstr), __VA_ARGS__); \
|
return format_to(ctx.out(), FMT_STRING(fmtstr), __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
template <> \
|
template <> \
|
||||||
|
@ -273,7 +272,7 @@ struct formatter<tp, wchar_t> { \
|
||||||
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \
|
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \
|
||||||
template <typename FormatContext> \
|
template <typename FormatContext> \
|
||||||
auto format(const tp &obj, FormatContext &ctx) { \
|
auto format(const tp &obj, FormatContext &ctx) { \
|
||||||
return format_to(ctx.out(), fmt(L##fmtstr), __VA_ARGS__); \
|
return format_to(ctx.out(), FMT_STRING(L##fmtstr), __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
template <> \
|
template <> \
|
||||||
|
@ -282,7 +281,7 @@ struct formatter<tp, char16_t> { \
|
||||||
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \
|
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \
|
||||||
template <typename FormatContext> \
|
template <typename FormatContext> \
|
||||||
auto format(const tp &obj, FormatContext &ctx) { \
|
auto format(const tp &obj, FormatContext &ctx) { \
|
||||||
return format_to(ctx.out(), fmt(u##fmtstr), __VA_ARGS__); \
|
return format_to(ctx.out(), FMT_STRING(u##fmtstr), __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
template <> \
|
template <> \
|
||||||
|
@ -291,7 +290,7 @@ struct formatter<tp, char32_t> { \
|
||||||
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \
|
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); } \
|
||||||
template <typename FormatContext> \
|
template <typename FormatContext> \
|
||||||
auto format(const tp &obj, FormatContext &ctx) { \
|
auto format(const tp &obj, FormatContext &ctx) { \
|
||||||
return format_to(ctx.out(), fmt(U##fmtstr), __VA_ARGS__); \
|
return format_to(ctx.out(), FMT_STRING(U##fmtstr), __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,20 +185,20 @@ void KillProcessTree() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
std::string cmdLineStr = fmt::format(fmt("atos -p {}"), getpid());
|
std::string cmdLineStr = fmt::format(FMT_STRING("atos -p {}"), getpid());
|
||||||
#else
|
#else
|
||||||
std::string cmdLineStr = fmt::format(fmt("2>/dev/null addr2line -C -f -e \"{}\""), exeNameBuffer);
|
std::string cmdLineStr = fmt::format(FMT_STRING("2>/dev/null addr2line -C -f -e \"{}\""), exeNameBuffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++) {
|
||||||
#if __linux__
|
#if __linux__
|
||||||
Dl_info dlip;
|
Dl_info dlip;
|
||||||
if (dladdr(array[i], &dlip))
|
if (dladdr(array[i], &dlip))
|
||||||
cmdLineStr += fmt::format(fmt(" 0x{:016X}"), (uintptr_t)((uint8_t*)array[i] - (uint8_t*)dlip.dli_fbase));
|
cmdLineStr += fmt::format(FMT_STRING(" 0x{:016X}"), (uintptr_t)((uint8_t*)array[i] - (uint8_t*)dlip.dli_fbase));
|
||||||
else
|
else
|
||||||
cmdLineStr += fmt::format(fmt(" 0x{:016X}"), (uintptr_t)array[i]);
|
cmdLineStr += fmt::format(FMT_STRING(" 0x{:016X}"), (uintptr_t)array[i]);
|
||||||
#else
|
#else
|
||||||
cmdLineStr += fmt::format(fmt(" 0x{:016X}"), (uintptr_t)array[i]);
|
cmdLineStr += fmt::format(FMT_STRING(" 0x{:016X}"), (uintptr_t)array[i]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,19 +245,19 @@ static void AbortHandler(int signum) {
|
||||||
_LogMutex.enabled = false;
|
_LogMutex.enabled = false;
|
||||||
switch (signum) {
|
switch (signum) {
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
Log.report(logvisor::Fatal, fmt("Segmentation Fault"));
|
Log.report(logvisor::Fatal, FMT_STRING("Segmentation Fault"));
|
||||||
break;
|
break;
|
||||||
case SIGILL:
|
case SIGILL:
|
||||||
Log.report(logvisor::Fatal, fmt("Bad Execution"));
|
Log.report(logvisor::Fatal, FMT_STRING("Bad Execution"));
|
||||||
break;
|
break;
|
||||||
case SIGFPE:
|
case SIGFPE:
|
||||||
Log.report(logvisor::Fatal, fmt("Floating Point Exception"));
|
Log.report(logvisor::Fatal, FMT_STRING("Floating Point Exception"));
|
||||||
break;
|
break;
|
||||||
case SIGABRT:
|
case SIGABRT:
|
||||||
Log.report(logvisor::Fatal, fmt("Abort Signal"));
|
Log.report(logvisor::Fatal, FMT_STRING("Abort Signal"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.report(logvisor::Fatal, fmt("unknown signal {}"), signum);
|
Log.report(logvisor::Fatal, FMT_STRING("unknown signal {}"), signum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,10 +336,10 @@ struct ConsoleLogger : public ILogger {
|
||||||
|
|
||||||
if (XtermColor) {
|
if (XtermColor) {
|
||||||
std::fputs(BOLD "[", stderr);
|
std::fputs(BOLD "[", stderr);
|
||||||
fmt::print(stderr, fmt(GREEN "{:.4f} "), tmd);
|
fmt::print(stderr, FMT_STRING(GREEN "{:.4f} "), tmd);
|
||||||
const uint_fast64_t fIdx = FrameIndex.load();
|
const uint_fast64_t fIdx = FrameIndex.load();
|
||||||
if (fIdx != 0)
|
if (fIdx != 0)
|
||||||
fmt::print(stderr, fmt("({}) "), fIdx);
|
fmt::print(stderr, FMT_STRING("({}) "), fIdx);
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case Info:
|
case Info:
|
||||||
std::fputs(BOLD CYAN "INFO", stderr);
|
std::fputs(BOLD CYAN "INFO", stderr);
|
||||||
|
@ -356,11 +356,11 @@ struct ConsoleLogger : public ILogger {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
fmt::print(stderr, fmt(NORMAL BOLD " {}"), modName);
|
fmt::print(stderr, FMT_STRING(NORMAL BOLD " {}"), modName);
|
||||||
if (sourceInfo)
|
if (sourceInfo)
|
||||||
fmt::print(stderr, fmt(BOLD YELLOW " {{}}"), sourceInfo);
|
fmt::print(stderr, FMT_STRING(BOLD YELLOW " {{}}"), sourceInfo);
|
||||||
if (thrName)
|
if (thrName)
|
||||||
fmt::print(stderr, fmt(BOLD MAGENTA " ({})"), thrName);
|
fmt::print(stderr, FMT_STRING(BOLD MAGENTA " ({})"), thrName);
|
||||||
std::fputs(NORMAL BOLD "] " NORMAL, stderr);
|
std::fputs(NORMAL BOLD "] " NORMAL, stderr);
|
||||||
} else {
|
} else {
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
|
@ -368,7 +368,7 @@ struct ConsoleLogger : public ILogger {
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
||||||
std::fputc('[', stderr);
|
std::fputc('[', stderr);
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
|
||||||
fmt::print(stderr, fmt("{:.4f} "), tmd);
|
fmt::print(stderr, FMT_STRING("{:.4f} "), tmd);
|
||||||
const uint64_t fi = FrameIndex.load();
|
const uint64_t fi = FrameIndex.load();
|
||||||
if (fi != 0)
|
if (fi != 0)
|
||||||
std::fprintf(stderr, "(%" PRIu64 ") ", fi);
|
std::fprintf(stderr, "(%" PRIu64 ") ", fi);
|
||||||
|
@ -393,23 +393,23 @@ struct ConsoleLogger : public ILogger {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
||||||
fmt::print(stderr, fmt(" {}"), modName);
|
fmt::print(stderr, FMT_STRING(" {}"), modName);
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
|
||||||
if (sourceInfo)
|
if (sourceInfo)
|
||||||
fmt::print(stderr, fmt(" {{}}"), sourceInfo);
|
fmt::print(stderr, FMT_STRING(" {{}}"), sourceInfo);
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
|
||||||
if (thrName)
|
if (thrName)
|
||||||
fmt::print(stderr, fmt(" ({})"), thrName);
|
fmt::print(stderr, FMT_STRING(" ({})"), thrName);
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
SetConsoleTextAttribute(Term, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
||||||
std::fputs("] ", stderr);
|
std::fputs("] ", stderr);
|
||||||
SetConsoleTextAttribute(Term, FOREGROUND_WHITE);
|
SetConsoleTextAttribute(Term, FOREGROUND_WHITE);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
std::fputc('[', stderr);
|
std::fputc('[', stderr);
|
||||||
fmt::print(stderr, fmt("{:.4f} "), tmd);
|
fmt::print(stderr, FMT_STRING("{:.4f} "), tmd);
|
||||||
uint_fast64_t fIdx = FrameIndex.load();
|
uint_fast64_t fIdx = FrameIndex.load();
|
||||||
if (fIdx)
|
if (fIdx)
|
||||||
fmt::print(stderr, fmt("({}) "), fIdx);
|
fmt::print(stderr, FMT_STRING("({}) "), fIdx);
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case Info:
|
case Info:
|
||||||
std::fputs("INFO", stderr);
|
std::fputs("INFO", stderr);
|
||||||
|
@ -426,11 +426,11 @@ struct ConsoleLogger : public ILogger {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fmt::print(stderr, fmt(" {}"), modName);
|
fmt::print(stderr, FMT_STRING(" {}"), modName);
|
||||||
if (sourceInfo)
|
if (sourceInfo)
|
||||||
fmt::print(stderr, fmt(" {{}}"), sourceInfo);
|
fmt::print(stderr, FMT_STRING(" {{}}"), sourceInfo);
|
||||||
if (thrName)
|
if (thrName)
|
||||||
fmt::print(stderr, fmt(" ({})"), thrName);
|
fmt::print(stderr, FMT_STRING(" ({})"), thrName);
|
||||||
std::fputs("] ", stderr);
|
std::fputs("] ", stderr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ struct ConsoleLogger : public ILogger {
|
||||||
|
|
||||||
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, fmt::string_view format,
|
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, fmt::string_view format,
|
||||||
fmt::format_args args) override {
|
fmt::format_args args) override {
|
||||||
_reportHead(modName, fmt::format(fmt("{}:{}"), file, linenum).c_str(), severity);
|
_reportHead(modName, fmt::format(FMT_STRING("{}:{}"), file, linenum).c_str(), severity);
|
||||||
fmt::vprint(stderr, format, args);
|
fmt::vprint(stderr, format, args);
|
||||||
std::fputc('\n', stderr);
|
std::fputc('\n', stderr);
|
||||||
std::fflush(stderr);
|
std::fflush(stderr);
|
||||||
|
@ -460,7 +460,7 @@ struct ConsoleLogger : public ILogger {
|
||||||
|
|
||||||
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, fmt::wstring_view format,
|
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, fmt::wstring_view format,
|
||||||
fmt::wformat_args args) override {
|
fmt::wformat_args args) override {
|
||||||
_reportHead(modName, fmt::format(fmt("{}:{}"), file, linenum).c_str(), severity);
|
_reportHead(modName, fmt::format(FMT_STRING("{}:{}"), file, linenum).c_str(), severity);
|
||||||
fmt::vprint(stderr, format, args);
|
fmt::vprint(stderr, format, args);
|
||||||
std::fputc('\n', stderr);
|
std::fputc('\n', stderr);
|
||||||
std::fflush(stderr);
|
std::fflush(stderr);
|
||||||
|
@ -563,7 +563,7 @@ struct FileLogger : public ILogger {
|
||||||
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, fmt::string_view format,
|
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, fmt::string_view format,
|
||||||
fmt::format_args args) override {
|
fmt::format_args args) override {
|
||||||
openFile();
|
openFile();
|
||||||
_reportHead(modName, fmt::format(fmt("{}:{}"), file, linenum).c_str(), severity);
|
_reportHead(modName, fmt::format(FMT_STRING("{}:{}"), file, linenum).c_str(), severity);
|
||||||
fmt::vprint(fp, format, args);
|
fmt::vprint(fp, format, args);
|
||||||
std::fputc('\n', fp);
|
std::fputc('\n', fp);
|
||||||
closeFile();
|
closeFile();
|
||||||
|
@ -572,7 +572,7 @@ struct FileLogger : public ILogger {
|
||||||
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, fmt::wstring_view format,
|
void reportSource(const char* modName, Level severity, const char* file, unsigned linenum, fmt::wstring_view format,
|
||||||
fmt::wformat_args args) override {
|
fmt::wformat_args args) override {
|
||||||
openFile();
|
openFile();
|
||||||
_reportHead(modName, fmt::format(fmt("{}:{}"), file, linenum).c_str(), severity);
|
_reportHead(modName, fmt::format(FMT_STRING("{}:{}"), file, linenum).c_str(), severity);
|
||||||
fmt::vprint(fp, format, args);
|
fmt::vprint(fp, format, args);
|
||||||
std::fputc('\n', fp);
|
std::fputc('\n', fp);
|
||||||
closeFile();
|
closeFile();
|
||||||
|
|
Loading…
Reference in New Issue