Files
azerothcore-wotlk/src/common/Packets/ByteBuffer.cpp
Kargatum 4af4cbd3d9 feat(Core/Logging): rework logging (#4692)
* feat(Core/Logging): rework logging

* correct level for sql.sql

* del unused config options

* Correct build

* correct after merge

* whitespace

20:29:37 1. 'Player.cpp'. Replace (1)
20:29:37 2. 'ObjectMgr.cpp'. Replace (3)

* 1

* correct logging

* correct affter merge

* 1

* 2

* LOG_LEVEL_WARN

* #include "AppenderDB.h"

* 3

* 4

* 5

* 1. 'WorldSocket.cpp'. Replace (1)

* 6

* 1
2021-04-17 11:20:07 +02:00

70 lines
1.7 KiB
C++

/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
#include "ByteBuffer.h"
#include "Common.h"
#include "Log.h"
#include <ace/Stack_Trace.h>
#include <sstream>
ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos,
size_t size, size_t valueSize)
{
std::ostringstream ss;
ss << "Attempted to " << (add ? "put" : "get") << " value with size: "
<< valueSize << " in ByteBuffer (pos: " << pos << " size: " << size
<< ")";
message().assign(ss.str());
}
ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size,
size_t valueSize)
{
std::ostringstream ss;
ss << "Attempted to put a "
<< (valueSize > 0 ? "NULL-pointer" : "zero-sized value")
<< " in ByteBuffer (pos: " << pos << " size: " << size << ")";
message().assign(ss.str());
}
void ByteBuffer::hexlike(bool outString) const
{
if (!outString)
return;
uint32 j = 1, k = 1;
std::ostringstream o;
o << "STORAGE_SIZE: " << size() << "\nCONTENTS:\n";
for (uint32 i = 0; i < size(); ++i)
{
char buf[3];
snprintf(buf, 3, "%02X", read<uint8>(i));
if ((i == (j * 8)) && ((i != (k * 16))))
{
o << "| ";
++j;
}
else if (i == (k * 16))
{
o << "\n";
++k;
++j;
}
o << buf << " ";
}
o << " ";
LOG_INFO("server", "%s", o.str().c_str());
}