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 /Tools/ProtoProxy | |
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 'Tools/ProtoProxy')
-rw-r--r-- | Tools/ProtoProxy/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tools/ProtoProxy/Connection.cpp | 28 | ||||
-rw-r--r-- | Tools/ProtoProxy/Connection.h | 8 | ||||
-rw-r--r-- | Tools/ProtoProxy/Globals.h | 9 |
4 files changed, 22 insertions, 26 deletions
diff --git a/Tools/ProtoProxy/CMakeLists.txt b/Tools/ProtoProxy/CMakeLists.txt index c64a97428..b5b1365a2 100644 --- a/Tools/ProtoProxy/CMakeLists.txt +++ b/Tools/ProtoProxy/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.0.2) project (ProtoProxy) include(../../SetFlags.cmake) @@ -100,5 +101,5 @@ add_executable(ProtoProxy ${SHARED_OSS_HDR} ) -target_link_libraries(ProtoProxy zlib mbedtls) +target_link_libraries(ProtoProxy zlib mbedtls fmt::fmt) diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index 940b9a7eb..9f602e873 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -10,6 +10,8 @@ #include "mbedTLS++/CryptoKey.h" #include "../../src/Logger.h" +#include "fmt/printf.h" + #ifdef _WIN32 #include <direct.h> // For _mkdir() #endif @@ -282,15 +284,12 @@ void cConnection::Run(void) -void cConnection::Log(const char * a_Format, ...) +void cConnection::Log(const char * a_Format, fmt::ArgList a_Args) { - va_list args; - va_start(args, a_Format); - AString msg; - AppendVPrintf(msg, a_Format, args); - va_end(args); - AString FullMsg; - Printf(FullMsg, "[%5.3f] %s\n", GetRelativeTime(), msg.c_str()); + fmt::MemoryWriter FullMsg; + fmt::printf(FullMsg, "[%5.3f] ", GetRelativeTime()); + fmt::printf(FullMsg, a_Format, a_Args); + fmt::printf(FullMsg, "\n"); // Log to file: cCSLock Lock(m_CSLog); @@ -307,16 +306,13 @@ void cConnection::Log(const char * a_Format, ...) -void cConnection::DataLog(const void * a_Data, size_t a_Size, const char * a_Format, ...) +void cConnection::DataLog(const void * a_Data, size_t a_Size, const char * a_Format, fmt::ArgList a_Args) { - va_list args; - va_start(args, a_Format); - AString msg; - AppendVPrintf(msg, a_Format, args); - va_end(args); - AString FullMsg; + fmt::MemoryWriter FullMsg; + fmt::printf(FullMsg, "[%5.3f] ", GetRelativeTime()); + fmt::printf(FullMsg, a_Format, a_Args); AString Hex; - Printf(FullMsg, "[%5.3f] %s\n%s\n", GetRelativeTime(), msg.c_str(), CreateHexDump(Hex, a_Data, a_Size, 16).c_str()); + fmt::printf(FullMsg, "\n%s\n", CreateHexDump(Hex, a_Data, a_Size, 16)); // Log to file: cCSLock Lock(m_CSLog); diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h index 2402e9f95..3b9127530 100644 --- a/Tools/ProtoProxy/Connection.h +++ b/Tools/ProtoProxy/Connection.h @@ -59,8 +59,12 @@ public: void Run(void); - void Log(const char * a_Format, ...); - void DataLog(const void * a_Data, size_t a_Size, const char * a_Format, ...); + void Log(const char * a_Format, fmt::ArgList); + FMT_VARIADIC(void, Log, const char *) + + void DataLog(const void * a_Data, size_t a_Size, const char * a_Format, fmt::ArgList); + FMT_VARIADIC(void, DataLog, const void *, size_t, const char *) + void LogFlush(void); protected: diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h index 0ce5ea878..a2d0664b0 100644 --- a/Tools/ProtoProxy/Globals.h +++ b/Tools/ProtoProxy/Globals.h @@ -22,8 +22,6 @@ #define ALIGN_8 #define ALIGN_16 - #define FORMATSTRING(formatIndex, va_argsIndex) - #elif defined(__GNUC__) // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)? @@ -37,8 +35,6 @@ // Some portability macros :) #define stricmp strcasecmp - #define FORMATSTRING(formatIndex, va_argsIndex) - #else #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler" @@ -57,8 +53,6 @@ #define ALIGN_16 */ - #define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex))) - #endif @@ -186,10 +180,11 @@ typedef unsigned char Byte; // Common headers (part 1, without macros): +#include "fmt/format.h" #include "StringUtils.h" #include "OSSupport/CriticalSection.h" - +#include "LoggerSimple.h" |