aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Packets/ByteBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/shared/Packets/ByteBuffer.h')
-rwxr-xr-xsrc/server/shared/Packets/ByteBuffer.h87
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: