diff options
author | Subv <s.v.h21@hotmail.com> | 2012-08-22 17:26:53 -0500 |
---|---|---|
committer | Subv <s.v.h21@hotmail.com> | 2012-08-22 17:26:53 -0500 |
commit | dc95ce61b46ce2d542ee4c4dbdf35a9e854c4316 (patch) | |
tree | e673101dc6554a76dfacb5cf3497dd1d2bde4f41 /src/server/shared/Packets/ByteBuffer.h | |
parent | cecaab7948d5289439d1334d7bedcaae90e1fe3a (diff) | |
parent | 85ed0e32a9b2b029c1db3cf1a914b3940cf72b9b (diff) |
Merge branch 'master' of github.com:TrinityCore/TrinityCore into mmaps
Conflicts:
dep/PackageList.txt
src/server/game/Movement/MotionMaster.cpp
src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
src/server/game/Movement/MovementGenerators/PointMovementGenerator.h
src/server/game/Movement/Spline/MoveSplineInit.h
src/server/game/World/World.h
Diffstat (limited to 'src/server/shared/Packets/ByteBuffer.h')
-rwxr-xr-x | src/server/shared/Packets/ByteBuffer.h | 87 |
1 files changed, 38 insertions, 49 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index fb2fdf09583..760fcfd48d9 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -50,8 +50,10 @@ class ByteBufferPositionException : public ByteBufferException protected: void PrintError() const { - sLog->outError("Attempted to %s value with size: "SIZEFMTD" in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD") " , - (_add ? "put" : "get"), ValueSize, Pos, Size); + ACE_Stack_Trace trace; + + sLog->outError(LOG_FILTER_GENERAL, "Attempted to %s value with size: "SIZEFMTD" in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD")\n[Stacktrace: %s]" , + (_add ? "put" : "get"), ValueSize, Pos, Size, trace.c_str()); } private: @@ -70,8 +72,10 @@ class ByteBufferSourceException : public ByteBufferException protected: void PrintError() const { - sLog->outError("Attempted to put a %s in ByteBuffer (pos: "SIZEFMTD" size: "SIZEFMTD")", - (ValueSize > 0 ? "NULL-pointer" : "zero-sized value"), Pos, Size); + ACE_Stack_Trace trace; + + sLog->outError(LOG_FILTER_GENERAL, "Attempted to put a %s in ByteBuffer (pos: "SIZEFMTD" size: "SIZEFMTD")\n[Stacktrace: %s]", + (ValueSize > 0 ? "NULL-pointer" : "zero-sized value"), Pos, Size, trace.c_str()); } }; @@ -185,8 +189,7 @@ class ByteBuffer ByteBuffer &operator<<(const char *str) { - size_t len = 0; - if (str && (len = strlen(str))) + if (size_t len = (str ? strlen(str) : 0)) append((uint8 const*)str, len); append((uint8)0); return *this; @@ -448,79 +451,65 @@ class ByteBuffer void print_storage() const { - if (!sLog->IsOutDebug()) // optimize disabled debug output + if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output return; - sLog->outDebug(LOG_FILTER_NETWORKIO, "STORAGE_SIZE: %lu", (unsigned long)size() ); + std::ostringstream o; + o << "STORAGE_SIZE: " << size(); for (uint32 i = 0; i < size(); ++i) - sLog->outDebugInLine("%u - ", read<uint8>(i) ); - sLog->outDebug(LOG_FILTER_NETWORKIO, " "); + o << read<uint8>(i) << " - "; + o << " "; + + sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str()); } void textlike() const { - if (!sLog->IsOutDebug()) // optimize disabled debug output + if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output return; - sLog->outDebug(LOG_FILTER_NETWORKIO, "STORAGE_SIZE: %lu", (unsigned long)size() ); + std::ostringstream o; + o << "STORAGE_SIZE: " << size(); for (uint32 i = 0; i < size(); ++i) - sLog->outDebugInLine("%c", read<uint8>(i) ); - sLog->outDebug(LOG_FILTER_NETWORKIO, " "); + { + char buf[1]; + snprintf(buf, 1, "%c", read<uint8>(i)); + o << buf; + } + o << " "; + sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str()); } void hexlike() const { - if (!sLog->IsOutDebug()) // optimize disabled debug output + if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output return; uint32 j = 1, k = 1; - sLog->outDebug(LOG_FILTER_NETWORKIO, "STORAGE_SIZE: %lu", (unsigned long)size() ); + + std::ostringstream o; + o << "STORAGE_SIZE: " << size(); for (uint32 i = 0; i < size(); ++i) { + char buf[3]; + snprintf(buf, 1, "%2X ", read<uint8>(i)); if ((i == (j * 8)) && ((i != (k * 16)))) { - if (read<uint8>(i) < 0x10) - { - sLog->outDebugInLine("| 0%X ", read<uint8>(i) ); - } - else - { - sLog->outDebugInLine("| %X ", read<uint8>(i) ); - } + o << "| "; ++j; } else if (i == (k * 16)) { - if (read<uint8>(i) < 0x10) - { - sLog->outDebugInLine("\n"); - - sLog->outDebugInLine("0%X ", read<uint8>(i) ); - } - else - { - sLog->outDebugInLine("\n"); - - sLog->outDebugInLine("%X ", read<uint8>(i) ); - } - + o << "\n"; ++k; ++j; } - else - { - if (read<uint8>(i) < 0x10) - { - sLog->outDebugInLine("0%X ", read<uint8>(i) ); - } - else - { - sLog->outDebugInLine("%X ", read<uint8>(i) ); - } - } + + o << buf; } - sLog->outDebugInLine("\n"); + o << " "; + sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str()); } protected: |