diff --git a/lib/MySQL_Logger.cpp b/lib/MySQL_Logger.cpp index 99bb9549b..a92bcd134 100644 --- a/lib/MySQL_Logger.cpp +++ b/lib/MySQL_Logger.cpp @@ -64,6 +64,7 @@ struct BufferTypeInfo { // Helper lambda to convert binary data to a hex string. auto binaryToHex = [](const MYSQL_BIND* bind, unsigned long len, std::string &out) { std::ostringstream oss; + oss << "0x"; const unsigned char* data = reinterpret_cast(bind->buffer); for (unsigned long i = 0; i < len; i++) { oss << std::setw(2) << std::setfill('0') << std::hex << (int)data[i]; @@ -109,7 +110,7 @@ static const std::unordered_map bufferTypeInfoMap }, { MYSQL_TYPE_TIMESTAMP, { "TIMESTAMP", [](const MYSQL_BIND* bind, unsigned long len, std::string &out) { - binaryToHex(bind, len, out); + binaryToHex(bind, sizeof(MYSQL_TIME), out); }} }, { MYSQL_TYPE_LONGLONG, @@ -125,17 +126,17 @@ static const std::unordered_map bufferTypeInfoMap }, { MYSQL_TYPE_DATE, { "DATE", [](const MYSQL_BIND* bind, unsigned long len, std::string &out) { - binaryToHex(bind, len, out); + binaryToHex(bind, sizeof(MYSQL_TIME), out); }} }, { MYSQL_TYPE_TIME, { "TIME", [](const MYSQL_BIND* bind, unsigned long len, std::string &out) { - binaryToHex(bind, len, out); + binaryToHex(bind, sizeof(MYSQL_TIME), out); }} }, { MYSQL_TYPE_DATETIME, { "DATETIME", [](const MYSQL_BIND* bind, unsigned long len, std::string &out) { - binaryToHex(bind, len, out); + binaryToHex(bind, sizeof(MYSQL_TIME), out); }} }, { MYSQL_TYPE_YEAR,