diff options
author | peterbell10 <peterbell10@live.co.uk> | 2018-01-03 18:41:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-03 18:41:16 +0100 |
commit | 757231cc6e777b8f4717d1467ef7efa01c7fde15 (patch) | |
tree | 6d1021761ad1c492700fe17560cb79520e508d60 /src/Globals.h | |
parent | Concrete mixing (#4096) (diff) | |
download | cuberite-757231cc6e777b8f4717d1467ef7efa01c7fde15.tar cuberite-757231cc6e777b8f4717d1467ef7efa01c7fde15.tar.gz cuberite-757231cc6e777b8f4717d1467ef7efa01c7fde15.tar.bz2 cuberite-757231cc6e777b8f4717d1467ef7efa01c7fde15.tar.lz cuberite-757231cc6e777b8f4717d1467ef7efa01c7fde15.tar.xz cuberite-757231cc6e777b8f4717d1467ef7efa01c7fde15.tar.zst cuberite-757231cc6e777b8f4717d1467ef7efa01c7fde15.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Globals.h | 101 |
1 files changed, 20 insertions, 81 deletions
diff --git a/src/Globals.h b/src/Globals.h index 78c0539fb..e48c6dbfe 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -38,13 +38,6 @@ #define OBSOLETE __declspec(deprecated) - #define FORMATSTRING(formatIndex, va_argsIndex) - - // MSVC has its own custom version of zu format - #define SIZE_T_FMT "%Iu" - #define SIZE_T_FMT_PRECISION(x) "%" #x "Iu" - #define SIZE_T_FMT_HEX "%Ix" - #define NORETURN __declspec(noreturn) #if (_MSC_VER < 1900) // noexcept support was added in VS 2015 #define NOEXCEPT throw() @@ -87,27 +80,6 @@ #define OBSOLETE __attribute__((deprecated)) - #define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex))) - - #if defined(_WIN32) - // We're compiling on MinGW, which uses an old MSVCRT library that has no support for size_t printfing. - // We need direct size formats: - #if defined(_WIN64) - #define SIZE_T_FMT "%I64u" - #define SIZE_T_FMT_PRECISION(x) "%" #x "I64u" - #define SIZE_T_FMT_HEX "%I64x" - #else - #define SIZE_T_FMT "%u" - #define SIZE_T_FMT_PRECISION(x) "%" #x "u" - #define SIZE_T_FMT_HEX "%x" - #endif - #else - // We're compiling on Linux, so we can use libc's size_t printf format: - #define SIZE_T_FMT "%zu" - #define SIZE_T_FMT_PRECISION(x) "%" #x "zu" - #define SIZE_T_FMT_HEX "%zx" - #endif - #define NORETURN __attribute((__noreturn__)) #define NOEXCEPT noexcept #define CAN_THROW noexcept(false) @@ -263,6 +235,7 @@ template class SizeChecker<UInt8, 1>; // Common headers (part 1, without macros): +#include "fmt/format.h" #include "StringUtils.h" #include "OSSupport/CriticalSection.h" #include "OSSupport/Event.h" @@ -271,73 +244,39 @@ template class SizeChecker<UInt8, 1>; #ifndef TEST_GLOBALS - // These functions are defined in Logger.cpp, but are declared here to avoid including all of logger.h - extern void LOG (const char * a_Format, ...) FORMATSTRING(1, 2); - extern void LOGINFO (const char * a_Format, ...) FORMATSTRING(1, 2); - extern void LOGWARNING(const char * a_Format, ...) FORMATSTRING(1, 2); - extern void LOGERROR (const char * a_Format, ...) FORMATSTRING(1, 2); - - // In debug builds, translate LOGD to LOG, otherwise leave it out altogether: - #ifdef _DEBUG - #define LOGD LOG - #else - #define LOGD(...) - #endif // _DEBUG - - #define LOGWARN LOGWARNING + #include "LoggerSimple.h" #else - // Logging functions - void inline LOGERROR(const char * a_Format, ...) FORMATSTRING(1, 2); + #include "fmt/printf.h" - void inline LOGERROR(const char * a_Format, ...) - { - va_list argList; - va_start(argList, a_Format); - vprintf(a_Format, argList); - putchar('\n'); - fflush(stdout); - va_end(argList); - } - - void inline LOGWARNING(const char * a_Format, ...) FORMATSTRING(1, 2); - - void inline LOGWARNING(const char * a_Format, ...) - { - va_list argList; - va_start(argList, a_Format); - vprintf(a_Format, argList); - putchar('\n'); - fflush(stdout); - va_end(argList); - } - - void inline LOGD(const char * a_Format, ...) FORMATSTRING(1, 2); - - void inline LOGD(const char * a_Format, ...) + // Logging functions + template <typename ... Args> + void LOG(const char * a_Format, const Args & ... a_Args) { - va_list argList; - va_start(argList, a_Format); - vprintf(a_Format, argList); + fmt::printf(a_Format, a_Args...); putchar('\n'); fflush(stdout); - va_end(argList); } - void inline LOG(const char * a_Format, ...) FORMATSTRING(1, 2); + #define LOGERROR LOG + #define LOGWARNING LOG + #define LOGD LOG + #define LOGINFO LOG + #define LOGWARN LOG - void inline LOG(const char * a_Format, ...) + template <typename ... Args> + void FLOG(const char * a_Format, const Args & ... a_Args) { - va_list argList; - va_start(argList, a_Format); - vprintf(a_Format, argList); + fmt::print(a_Format, a_Args...); putchar('\n'); fflush(stdout); - va_end(argList); } - #define LOGINFO LOG - #define LOGWARN LOGWARNING + #define FLOGERROR FLOG + #define FLOGWARNING FLOG + #define FLOGD FLOG + #define FLOGINFO FLOG + #define FLOGWARN FLOG #endif |