mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[9836] Make log output code more consistent for diff build modes.
* Make possible have debug output if build in release mode. * But preserver current optimization in avoid debug output args calculation if debug ouput disabled if done using DEBUG_LOG * Implement in same way BASIC_LOG, DETAIL_LOG. Recommended use its instead explicit access to sLog * Use variadic macros for DEBUG_LOG and other new defines. All supported VS/GCC have its support as C++ extension. * Add DEBUG_FILTER_LOG and semilar defines for filered log output and use its. * Also move recent added debug output for transport events under LOG_FILTER_TRANSPORT_MOVES
This commit is contained in:
parent
6726a08b48
commit
6dec6c8a9f
12 changed files with 168 additions and 179 deletions
|
|
@ -616,10 +616,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
|
||||||
if(GetPlayer()->GetSession()->PlayerLoading())
|
if(GetPlayer()->GetSession()->PlayerLoading())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_ACHIEVEMENT_UPDATES, "AchievementMgr::SendAchievementEarned(%u)", achievement->ID);
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_ACHIEVEMENT_UPDATES)==0)
|
|
||||||
sLog.outDebug("AchievementMgr::SendAchievementEarned(%u)", achievement->ID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()))
|
if(Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,10 +65,7 @@ VisibleNotifier::Notify()
|
||||||
{
|
{
|
||||||
i_player.m_clientGUIDs.erase(*itr);
|
i_player.m_clientGUIDs.erase(*itr);
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is out of range (no in active cells set) now for player %u",itr->GetString().c_str(),i_player.GetGUIDLow());
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
|
||||||
sLog.outDebug("%s is out of range (no in active cells set) now for player %u",itr->GetString().c_str(),i_player.GetGUIDLow());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// send update to other players (except player updates that already sent using SendUpdateToPlayer)
|
// send update to other players (except player updates that already sent using SendUpdateToPlayer)
|
||||||
|
|
|
||||||
|
|
@ -864,10 +864,7 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang
|
||||||
// delay creature move for grid/cell to grid/cell moves
|
// delay creature move for grid/cell to grid/cell moves
|
||||||
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
|
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
|
||||||
{
|
{
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) added to moving list from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", creature->GetGUIDLow(), creature->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
|
||||||
if ((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES) == 0)
|
|
||||||
sLog.outDebug("Creature (GUID: %u Entry: %u) added to moving list from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", creature->GetGUIDLow(), creature->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// do move or do move to respawn or remove creature if previous all fail
|
// do move or do move to respawn or remove creature if previous all fail
|
||||||
if(CreatureCellRelocation(creature,new_cell))
|
if(CreatureCellRelocation(creature,new_cell))
|
||||||
|
|
@ -885,10 +882,7 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang
|
||||||
if(!CreatureRespawnRelocation(creature))
|
if(!CreatureRespawnRelocation(creature))
|
||||||
{
|
{
|
||||||
// ... or unload (if respawn grid also not loaded)
|
// ... or unload (if respawn grid also not loaded)
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",creature->GetGUIDLow(),creature->GetEntry());
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
|
|
||||||
sLog.outDebug("Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",creature->GetGUIDLow(),creature->GetEntry());
|
|
||||||
#endif
|
|
||||||
creature->SetNeedNotify();
|
creature->SetNeedNotify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -910,10 +904,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
|
||||||
// if in same cell then none do
|
// if in same cell then none do
|
||||||
if(old_cell.DiffCell(new_cell))
|
if(old_cell.DiffCell(new_cell))
|
||||||
{
|
{
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) moved in grid[%u,%u] from cell[%u,%u] to cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
|
|
||||||
sLog.outDebug("Creature (GUID: %u Entry: %u) moved in grid[%u,%u] from cell[%u,%u] to cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( !old_cell.DiffGrid(new_cell) )
|
if( !old_cell.DiffGrid(new_cell) )
|
||||||
{
|
{
|
||||||
|
|
@ -924,10 +915,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) move in same grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
|
|
||||||
sLog.outDebug("Creature (GUID: %u Entry: %u) move in same grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -938,10 +926,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
|
||||||
{
|
{
|
||||||
EnsureGridLoadedAtEnter(new_cell);
|
EnsureGridLoadedAtEnter(new_cell);
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Active creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
|
|
||||||
sLog.outDebug("Active creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell);
|
RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell);
|
||||||
AddToGrid(c,getNGrid(new_cell.GridX(), new_cell.GridY()),new_cell);
|
AddToGrid(c,getNGrid(new_cell.GridX(), new_cell.GridY()),new_cell);
|
||||||
|
|
@ -952,10 +937,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
|
||||||
// in diff. loaded grid normal creature
|
// in diff. loaded grid normal creature
|
||||||
if(loaded(GridPair(new_cell.GridX(), new_cell.GridY())))
|
if(loaded(GridPair(new_cell.GridX(), new_cell.GridY())))
|
||||||
{
|
{
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
|
|
||||||
sLog.outDebug("Creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell);
|
RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_cell);
|
||||||
{
|
{
|
||||||
|
|
@ -967,10 +949,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fail to move: normal creature attempt move to unloaded grid
|
// fail to move: normal creature attempt move to unloaded grid
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
|
|
||||||
sLog.outDebug("Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -985,10 +964,7 @@ bool Map::CreatureRespawnRelocation(Creature *c)
|
||||||
c->CombatStop();
|
c->CombatStop();
|
||||||
c->GetMotionMaster()->Clear();
|
c->GetMotionMaster()->Clear();
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) will moved from grid[%u,%u]cell[%u,%u] to respawn grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
|
|
||||||
sLog.outDebug("Creature (GUID: %u Entry: %u) will moved from grid[%u,%u]cell[%u,%u] to respawn grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// teleport it to respawn point (like normal respawn if player see)
|
// teleport it to respawn point (like normal respawn if player see)
|
||||||
if(CreatureCellRelocation(c,resp_cell))
|
if(CreatureCellRelocation(c,resp_cell))
|
||||||
|
|
|
||||||
|
|
@ -17132,7 +17132,7 @@ void Player::_SaveStats()
|
||||||
|
|
||||||
void Player::outDebugValues() const
|
void Player::outDebugValues() const
|
||||||
{
|
{
|
||||||
if(!sLog.IsOutDebug()) // optimize disabled debug output
|
if(!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sLog.outDebug("HP is: \t\t\t%u\t\tMP is: \t\t\t%u",GetMaxHealth(), GetMaxPower(POWER_MANA));
|
sLog.outDebug("HP is: \t\t\t%u\t\tMP is: \t\t\t%u",GetMaxHealth(), GetMaxPower(POWER_MANA));
|
||||||
|
|
@ -17963,10 +17963,7 @@ void Player::HandleStealthedUnitsDetection()
|
||||||
(*i)->SendCreateUpdateToPlayer(this);
|
(*i)->SendCreateUpdateToPlayer(this);
|
||||||
m_clientGUIDs.insert(i_guid);
|
m_clientGUIDs.insert(i_guid);
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is detected in stealth by player %u. Distance = %f",i_guid.GetString().c_str(),GetGUIDLow(),GetDistance(*i));
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
|
||||||
sLog.outDebug("%s is detected in stealth by player %u. Distance = %f",i_guid.GetString().c_str(),GetGUIDLow(),GetDistance(*i));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// target aura duration for caster show only if target exist at caster client
|
// target aura duration for caster show only if target exist at caster client
|
||||||
// send data at target visibility change (adding to client)
|
// send data at target visibility change (adding to client)
|
||||||
|
|
@ -19145,10 +19142,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe
|
||||||
target->DestroyForPlayer(this);
|
target->DestroyForPlayer(this);
|
||||||
m_clientGUIDs.erase(t_guid);
|
m_clientGUIDs.erase(t_guid);
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s out of range for player %u. Distance = %f",t_guid.GetString().c_str(),GetGUIDLow(),GetDistance(target));
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
|
||||||
sLog.outDebug("%s out of range for player %u. Distance = %f",t_guid.GetString().c_str(),GetGUIDLow(),GetDistance(target));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -19159,10 +19153,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe
|
||||||
if(target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport())
|
if(target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport())
|
||||||
m_clientGUIDs.insert(target->GetObjectGuid());
|
m_clientGUIDs.insert(target->GetObjectGuid());
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "Object %u (Type: %u) is visible now for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target));
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
|
||||||
sLog.outDebug("Object %u (Type: %u) is visible now for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// target aura duration for caster show only if target exist at caster client
|
// target aura duration for caster show only if target exist at caster client
|
||||||
// send data at target visibility change (adding to client)
|
// send data at target visibility change (adding to client)
|
||||||
|
|
@ -19202,10 +19193,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD
|
||||||
target->BuildOutOfRangeUpdateBlock(&data);
|
target->BuildOutOfRangeUpdateBlock(&data);
|
||||||
m_clientGUIDs.erase(t_guid);
|
m_clientGUIDs.erase(t_guid);
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is out of range for %s. Distance = %f", t_guid.GetString().c_str(), GetObjectGuid().GetString().c_str(), GetDistance(target));
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
|
||||||
sLog.outDebug("%s is out of range for %s. Distance = %f",t_guid.GetString().c_str(),GetObjectGuid().GetString().c_str(),GetDistance(target));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -19216,10 +19204,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD
|
||||||
target->BuildCreateUpdateBlockForPlayer(&data, this);
|
target->BuildCreateUpdateBlockForPlayer(&data, this);
|
||||||
UpdateVisibilityOf_helper(m_clientGUIDs,target);
|
UpdateVisibilityOf_helper(m_clientGUIDs,target);
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is visible now for %s. Distance = %f", target->GetObjectGuid().GetString().c_str(), GetObjectGuid().GetString().c_str(), GetDistance(target));
|
||||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
|
||||||
sLog.outDebug("%s is visible now for %s. Distance = %f",target->GetObjectGuid().GetString().c_str(),GetObjectGuid().GetString().c_str(),GetDistance(target));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,7 @@ void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure
|
||||||
{
|
{
|
||||||
if (uint32 eventid = departure ? node.second.departureEventID : node.second.arrivalEventID)
|
if (uint32 eventid = departure ? node.second.departureEventID : node.second.arrivalEventID)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Taxi %s event %u of node %u of %s (%s) path", departure ? "departure" : "arrival", eventid, node.first, GetName(), GetObjectGuid().GetString().c_str());
|
DEBUG_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "Taxi %s event %u of node %u of %s (%s) path", departure ? "departure" : "arrival", eventid, node.first, GetName(), GetObjectGuid().GetString().c_str());
|
||||||
GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
|
GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ bool WorldSession::Update(uint32 /*diff*/)
|
||||||
else if(_player->IsInWorld())
|
else if(_player->IsInWorld())
|
||||||
{
|
{
|
||||||
(this->*opHandle.handler)(*packet);
|
(this->*opHandle.handler)(*packet);
|
||||||
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
|
if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
|
||||||
LogUnprocessedTail(packet);
|
LogUnprocessedTail(packet);
|
||||||
}
|
}
|
||||||
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
|
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
|
||||||
|
|
@ -200,7 +200,7 @@ bool WorldSession::Update(uint32 /*diff*/)
|
||||||
{
|
{
|
||||||
// not expected _player or must checked in packet hanlder
|
// not expected _player or must checked in packet hanlder
|
||||||
(this->*opHandle.handler)(*packet);
|
(this->*opHandle.handler)(*packet);
|
||||||
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
|
if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
|
||||||
LogUnprocessedTail(packet);
|
LogUnprocessedTail(packet);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -212,7 +212,7 @@ bool WorldSession::Update(uint32 /*diff*/)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(this->*opHandle.handler)(*packet);
|
(this->*opHandle.handler)(*packet);
|
||||||
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
|
if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
|
||||||
LogUnprocessedTail(packet);
|
LogUnprocessedTail(packet);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -230,7 +230,7 @@ bool WorldSession::Update(uint32 /*diff*/)
|
||||||
m_playerRecentlyLogout = false;
|
m_playerRecentlyLogout = false;
|
||||||
|
|
||||||
(this->*opHandle.handler)(*packet);
|
(this->*opHandle.handler)(*packet);
|
||||||
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
|
if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
|
||||||
LogUnprocessedTail(packet);
|
LogUnprocessedTail(packet);
|
||||||
break;
|
break;
|
||||||
case STATUS_NEVER:
|
case STATUS_NEVER:
|
||||||
|
|
@ -254,7 +254,7 @@ bool WorldSession::Update(uint32 /*diff*/)
|
||||||
{
|
{
|
||||||
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
|
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
|
||||||
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
|
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
|
||||||
if(sLog.IsOutDebug())
|
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
|
||||||
{
|
{
|
||||||
sLog.outDebug("Dumping error causing packet:");
|
sLog.outDebug("Dumping error causing packet:");
|
||||||
packet->hexlike();
|
packet->hexlike();
|
||||||
|
|
|
||||||
|
|
@ -718,7 +718,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
|
||||||
{
|
{
|
||||||
sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i.",
|
sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i.",
|
||||||
opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1);
|
opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1);
|
||||||
if(sLog.IsOutDebug())
|
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
|
||||||
{
|
{
|
||||||
sLog.outDebug("Dumping error-causing packet:");
|
sLog.outDebug("Dumping error-causing packet:");
|
||||||
new_pct->hexlike();
|
new_pct->hexlike();
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address)
|
||||||
m_addr = address;
|
m_addr = address;
|
||||||
m_port = port;
|
m_port = port;
|
||||||
|
|
||||||
if (!sLog.IsOutDebug ())
|
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
|
||||||
ACE_Log_Msg::instance ()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS);
|
ACE_Log_Msg::instance ()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS);
|
||||||
|
|
||||||
if (StartReactiveIO (port, address.c_str()) == -1)
|
if (StartReactiveIO (port, address.c_str()) == -1)
|
||||||
|
|
|
||||||
|
|
@ -412,7 +412,7 @@ class ByteBuffer
|
||||||
|
|
||||||
void print_storage() const
|
void print_storage() const
|
||||||
{
|
{
|
||||||
if(!sLog.IsOutDebug()) // optimize disabled debug output
|
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
|
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
|
||||||
|
|
@ -423,7 +423,7 @@ class ByteBuffer
|
||||||
|
|
||||||
void textlike() const
|
void textlike() const
|
||||||
{
|
{
|
||||||
if(!sLog.IsOutDebug()) // optimize disabled debug output
|
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
|
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
|
||||||
|
|
@ -434,13 +434,13 @@ class ByteBuffer
|
||||||
|
|
||||||
void hexlike() const
|
void hexlike() const
|
||||||
{
|
{
|
||||||
if(!sLog.IsOutDebug()) // optimize disabled debug output
|
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 j = 1, k = 1;
|
uint32 j = 1, k = 1;
|
||||||
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
|
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
|
||||||
|
|
||||||
if(sLog.IsIncludeTime())
|
if (sLog.IsIncludeTime())
|
||||||
sLog.outDebugInLine(" ");
|
sLog.outDebugInLine(" ");
|
||||||
|
|
||||||
for(uint32 i = 0; i < size(); ++i)
|
for(uint32 i = 0; i < size(); ++i)
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ Log::Log() :
|
||||||
|
|
||||||
void Log::InitColors(const std::string& str)
|
void Log::InitColors(const std::string& str)
|
||||||
{
|
{
|
||||||
if(str.empty())
|
if (str.empty())
|
||||||
{
|
{
|
||||||
m_colored = false;
|
m_colored = false;
|
||||||
return;
|
return;
|
||||||
|
|
@ -159,33 +159,41 @@ void Log::ResetColor(bool stdout_stream)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::SetLogLevel(char *Level)
|
void Log::SetLogLevel(char* level)
|
||||||
{
|
{
|
||||||
int32 NewLevel =atoi((char*)Level);
|
int32 newLevel =atoi((char*)level);
|
||||||
if ( NewLevel <0 )
|
|
||||||
NewLevel = 0;
|
|
||||||
m_logLevel = NewLevel;
|
|
||||||
|
|
||||||
printf( "LogLevel is %u\n",m_logLevel );
|
if (newLevel < LOG_LVL_MINIMAL)
|
||||||
|
newLevel = LOG_LVL_MINIMAL;
|
||||||
|
else if (newLevel > LOG_LVL_DEBUG)
|
||||||
|
newLevel = LOG_LVL_DEBUG;
|
||||||
|
|
||||||
|
m_logLevel = LogLevel(newLevel);
|
||||||
|
|
||||||
|
printf("LogLevel is %u\n", m_logLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::SetLogFileLevel(char *Level)
|
void Log::SetLogFileLevel(char* level)
|
||||||
{
|
{
|
||||||
int32 NewLevel =atoi((char*)Level);
|
int32 newLevel =atoi((char*)level);
|
||||||
if ( NewLevel <0 )
|
|
||||||
NewLevel = 0;
|
|
||||||
m_logFileLevel = NewLevel;
|
|
||||||
|
|
||||||
printf( "LogFileLevel is %u\n",m_logFileLevel );
|
if (newLevel < LOG_LVL_MINIMAL)
|
||||||
|
newLevel = LOG_LVL_MINIMAL;
|
||||||
|
else if (newLevel > LOG_LVL_DEBUG)
|
||||||
|
newLevel = LOG_LVL_DEBUG;
|
||||||
|
|
||||||
|
m_logFileLevel = LogLevel(newLevel);
|
||||||
|
|
||||||
|
printf("LogFileLevel is %u\n", m_logFileLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::Initialize()
|
void Log::Initialize()
|
||||||
{
|
{
|
||||||
/// Common log files data
|
/// Common log files data
|
||||||
m_logsDir = sConfig.GetStringDefault("LogsDir","");
|
m_logsDir = sConfig.GetStringDefault("LogsDir","");
|
||||||
if(!m_logsDir.empty())
|
if (!m_logsDir.empty())
|
||||||
{
|
{
|
||||||
if((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
|
if ((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
|
||||||
m_logsDir.append("/");
|
m_logsDir.append("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,20 +203,20 @@ void Log::Initialize()
|
||||||
logfile = openLogFile("LogFile","LogTimestamp","w");
|
logfile = openLogFile("LogFile","LogTimestamp","w");
|
||||||
|
|
||||||
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
|
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
|
||||||
if(!m_gmlog_per_account)
|
if (!m_gmlog_per_account)
|
||||||
gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
|
gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// GM log settings for per account case
|
// GM log settings for per account case
|
||||||
m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", "");
|
m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", "");
|
||||||
if(!m_gmlog_filename_format.empty())
|
if (!m_gmlog_filename_format.empty())
|
||||||
{
|
{
|
||||||
bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp",false);
|
bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp",false);
|
||||||
|
|
||||||
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
|
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
|
||||||
if(dot_pos!=m_gmlog_filename_format.npos)
|
if (dot_pos!=m_gmlog_filename_format.npos)
|
||||||
{
|
{
|
||||||
if(m_gmlog_timestamp)
|
if (m_gmlog_timestamp)
|
||||||
m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);
|
m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);
|
||||||
|
|
||||||
m_gmlog_filename_format.insert(dot_pos,"_#%u");
|
m_gmlog_filename_format.insert(dot_pos,"_#%u");
|
||||||
|
|
@ -217,7 +225,7 @@ void Log::Initialize()
|
||||||
{
|
{
|
||||||
m_gmlog_filename_format += "_#%u";
|
m_gmlog_filename_format += "_#%u";
|
||||||
|
|
||||||
if(m_gmlog_timestamp)
|
if (m_gmlog_timestamp)
|
||||||
m_gmlog_filename_format += m_logsTimestamp;
|
m_gmlog_filename_format += m_logsTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -232,19 +240,19 @@ void Log::Initialize()
|
||||||
|
|
||||||
// Main log file settings
|
// Main log file settings
|
||||||
m_includeTime = sConfig.GetBoolDefault("LogTime", false);
|
m_includeTime = sConfig.GetBoolDefault("LogTime", false);
|
||||||
m_logLevel = sConfig.GetIntDefault("LogLevel", 0);
|
m_logLevel = LogLevel(sConfig.GetIntDefault("LogLevel", 0));
|
||||||
m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
|
m_logFileLevel = LogLevel(sConfig.GetIntDefault("LogFileLevel", 0));
|
||||||
InitColors(sConfig.GetStringDefault("LogColors", ""));
|
InitColors(sConfig.GetStringDefault("LogColors", ""));
|
||||||
|
|
||||||
m_logFilter = 0;
|
m_logFilter = 0;
|
||||||
|
|
||||||
if(sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
|
if (sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
|
||||||
m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
|
m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
|
||||||
if(sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
|
if (sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
|
||||||
m_logFilter |= LOG_FILTER_CREATURE_MOVES;
|
m_logFilter |= LOG_FILTER_CREATURE_MOVES;
|
||||||
if(sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
|
if (sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
|
||||||
m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
|
m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
|
||||||
if(sConfig.GetBoolDefault("LogFilter_AchievementUpdates", true))
|
if (sConfig.GetBoolDefault("LogFilter_AchievementUpdates", true))
|
||||||
m_logFilter |= LOG_FILTER_ACHIEVEMENT_UPDATES;
|
m_logFilter |= LOG_FILTER_ACHIEVEMENT_UPDATES;
|
||||||
|
|
||||||
// Char log settings
|
// Char log settings
|
||||||
|
|
@ -254,13 +262,13 @@ void Log::Initialize()
|
||||||
FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode)
|
FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode)
|
||||||
{
|
{
|
||||||
std::string logfn=sConfig.GetStringDefault(configFileName, "");
|
std::string logfn=sConfig.GetStringDefault(configFileName, "");
|
||||||
if(logfn.empty())
|
if (logfn.empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if(configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag,false))
|
if (configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag,false))
|
||||||
{
|
{
|
||||||
size_t dot_pos = logfn.find_last_of(".");
|
size_t dot_pos = logfn.find_last_of(".");
|
||||||
if(dot_pos!=logfn.npos)
|
if (dot_pos!=logfn.npos)
|
||||||
logfn.insert(dot_pos,m_logsTimestamp);
|
logfn.insert(dot_pos,m_logsTimestamp);
|
||||||
else
|
else
|
||||||
logfn += m_logsTimestamp;
|
logfn += m_logsTimestamp;
|
||||||
|
|
@ -271,7 +279,7 @@ FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFla
|
||||||
|
|
||||||
FILE* Log::openGmlogPerAccount(uint32 account)
|
FILE* Log::openGmlogPerAccount(uint32 account)
|
||||||
{
|
{
|
||||||
if(m_gmlog_filename_format.empty())
|
if (m_gmlog_filename_format.empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char namebuf[MANGOS_PATH_MAX];
|
char namebuf[MANGOS_PATH_MAX];
|
||||||
|
|
@ -322,20 +330,20 @@ std::string Log::GetTimestampStr()
|
||||||
|
|
||||||
void Log::outTitle( const char * str)
|
void Log::outTitle( const char * str)
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(true,WHITE);
|
SetColor(true,WHITE);
|
||||||
|
|
||||||
// not expected utf8 and then send as-is
|
// not expected utf8 and then send as-is
|
||||||
printf("%s", str);
|
printf("%s", str);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if(logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
fprintf(logfile, "%s", str);
|
fprintf(logfile, "%s", str);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
|
|
@ -347,27 +355,28 @@ void Log::outTitle( const char * str)
|
||||||
|
|
||||||
void Log::outString()
|
void Log::outString()
|
||||||
{
|
{
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
if(logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
fflush(logfile);
|
fflush(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outString( const char * str, ... )
|
void Log::outString( const char * str, ... )
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(true,m_colors[LogNormal]);
|
SetColor(true,m_colors[LogNormal]);
|
||||||
|
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -376,11 +385,12 @@ void Log::outString( const char * str, ... )
|
||||||
vutf8printf(stdout, str, &ap);
|
vutf8printf(stdout, str, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
if(logfile)
|
|
||||||
|
if (logfile)
|
||||||
{
|
{
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
|
|
||||||
|
|
@ -391,18 +401,19 @@ void Log::outString( const char * str, ... )
|
||||||
|
|
||||||
fflush(logfile);
|
fflush(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outError( const char * err, ... )
|
void Log::outError( const char * err, ... )
|
||||||
{
|
{
|
||||||
if( !err )
|
if (!err)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(false,m_colors[LogError]);
|
SetColor(false,m_colors[LogError]);
|
||||||
|
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -411,11 +422,11 @@ void Log::outError( const char * err, ... )
|
||||||
vutf8printf(stderr, err, &ap);
|
vutf8printf(stderr, err, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(false);
|
ResetColor(false);
|
||||||
|
|
||||||
fprintf( stderr, "\n" );
|
fprintf( stderr, "\n" );
|
||||||
if(logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
fprintf(logfile, "ERROR:" );
|
fprintf(logfile, "ERROR:" );
|
||||||
|
|
@ -427,18 +438,19 @@ void Log::outError( const char * err, ... )
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
fflush(logfile);
|
fflush(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outErrorDb( const char * err, ... )
|
void Log::outErrorDb( const char * err, ... )
|
||||||
{
|
{
|
||||||
if( !err )
|
if (!err)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(false,m_colors[LogError]);
|
SetColor(false,m_colors[LogError]);
|
||||||
|
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -447,12 +459,12 @@ void Log::outErrorDb( const char * err, ... )
|
||||||
vutf8printf(stderr, err, &ap);
|
vutf8printf(stderr, err, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(false);
|
ResetColor(false);
|
||||||
|
|
||||||
fprintf( stderr, "\n" );
|
fprintf( stderr, "\n" );
|
||||||
|
|
||||||
if(logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
fprintf(logfile, "ERROR:" );
|
fprintf(logfile, "ERROR:" );
|
||||||
|
|
@ -465,7 +477,7 @@ void Log::outErrorDb( const char * err, ... )
|
||||||
fflush(logfile);
|
fflush(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dberLogfile)
|
if (dberLogfile)
|
||||||
{
|
{
|
||||||
outTimestamp(dberLogfile);
|
outTimestamp(dberLogfile);
|
||||||
|
|
||||||
|
|
@ -477,20 +489,21 @@ void Log::outErrorDb( const char * err, ... )
|
||||||
fprintf(dberLogfile, "\n" );
|
fprintf(dberLogfile, "\n" );
|
||||||
fflush(dberLogfile);
|
fflush(dberLogfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outBasic( const char * str, ... )
|
void Log::outBasic( const char * str, ... )
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( m_logLevel > 0 )
|
if (m_logLevel >= LOG_LVL_BASIC)
|
||||||
{
|
{
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(true,m_colors[LogDetails]);
|
SetColor(true,m_colors[LogDetails]);
|
||||||
|
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -498,13 +511,13 @@ void Log::outBasic( const char * str, ... )
|
||||||
vutf8printf(stdout, str, &ap);
|
vutf8printf(stdout, str, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(logfile && m_logFileLevel > 0)
|
if (logfile && m_logFileLevel >= LOG_LVL_BASIC)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
|
|
@ -514,21 +527,22 @@ void Log::outBasic( const char * str, ... )
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fflush(logfile);
|
fflush(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outDetail( const char * str, ... )
|
void Log::outDetail( const char * str, ... )
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( m_logLevel > 1 )
|
if (m_logLevel >= LOG_LVL_DETAIL)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(true,m_colors[LogDetails]);
|
SetColor(true,m_colors[LogDetails]);
|
||||||
|
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -536,12 +550,13 @@ void Log::outDetail( const char * str, ... )
|
||||||
vutf8printf(stdout, str, &ap);
|
vutf8printf(stdout, str, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
if(logfile && m_logFileLevel > 1)
|
|
||||||
|
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
|
||||||
{
|
{
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
|
|
||||||
|
|
@ -559,11 +574,12 @@ void Log::outDetail( const char * str, ... )
|
||||||
|
|
||||||
void Log::outDebugInLine( const char * str, ... )
|
void Log::outDebugInLine( const char * str, ... )
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
if( m_logLevel > 2 )
|
|
||||||
|
if (m_logLevel >= LOG_LVL_DEBUG)
|
||||||
{
|
{
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(true,m_colors[LogDebug]);
|
SetColor(true,m_colors[LogDebug]);
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -571,10 +587,11 @@ void Log::outDebugInLine( const char * str, ... )
|
||||||
vutf8printf(stdout, str, &ap);
|
vutf8printf(stdout, str, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
}
|
}
|
||||||
if(logfile && m_logFileLevel > 2)
|
|
||||||
|
if (logfile && m_logFileLevel >= LOG_LVL_DEBUG)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
|
|
@ -585,14 +602,15 @@ void Log::outDebugInLine( const char * str, ... )
|
||||||
|
|
||||||
void Log::outDebug( const char * str, ... )
|
void Log::outDebug( const char * str, ... )
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
if( m_logLevel > 2 )
|
|
||||||
|
if (m_logLevel >= LOG_LVL_DEBUG)
|
||||||
{
|
{
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(true,m_colors[LogDebug]);
|
SetColor(true,m_colors[LogDebug]);
|
||||||
|
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -600,12 +618,13 @@ void Log::outDebug( const char * str, ... )
|
||||||
vutf8printf(stdout, str, &ap);
|
vutf8printf(stdout, str, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
if(logfile && m_logFileLevel > 2)
|
|
||||||
|
if (logfile && m_logFileLevel >= LOG_LVL_DEBUG)
|
||||||
{
|
{
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
|
|
||||||
|
|
@ -617,20 +636,21 @@ void Log::outDebug( const char * str, ... )
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
fflush(logfile);
|
fflush(logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outCommand( uint32 account, const char * str, ... )
|
void Log::outCommand( uint32 account, const char * str, ... )
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( m_logLevel > 1 )
|
if (m_logLevel >= LOG_LVL_DETAIL)
|
||||||
{
|
{
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
SetColor(true,m_colors[LogDetails]);
|
SetColor(true,m_colors[LogDetails]);
|
||||||
|
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -638,12 +658,13 @@ void Log::outCommand( uint32 account, const char * str, ... )
|
||||||
vutf8printf(stdout, str, &ap);
|
vutf8printf(stdout, str, &ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if(m_colored)
|
if (m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
}
|
}
|
||||||
if(logfile && m_logFileLevel > 1)
|
|
||||||
|
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
|
|
@ -687,7 +708,7 @@ void Log::outChar(const char * str, ... )
|
||||||
if (!str)
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(charLogfile)
|
if (charLogfile)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
outTimestamp(charLogfile);
|
outTimestamp(charLogfile);
|
||||||
|
|
@ -725,7 +746,7 @@ void Log::outWorldPacketDump( uint32 socket, uint32 opcode, char const* opcodeNa
|
||||||
|
|
||||||
void Log::outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name )
|
void Log::outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name )
|
||||||
{
|
{
|
||||||
if(charLogfile)
|
if (charLogfile)
|
||||||
{
|
{
|
||||||
fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n",account_id,guid,name,str );
|
fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n",account_id,guid,name,str );
|
||||||
fflush(charLogfile);
|
fflush(charLogfile);
|
||||||
|
|
@ -734,12 +755,12 @@ void Log::outCharDump( const char * str, uint32 account_id, uint32 guid, const c
|
||||||
|
|
||||||
void Log::outMenu( const char * str, ... )
|
void Log::outMenu( const char * str, ... )
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetColor(true,m_colors[LogNormal]);
|
SetColor(true,m_colors[LogNormal]);
|
||||||
|
|
||||||
if(m_includeTime)
|
if (m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -750,7 +771,7 @@ void Log::outMenu( const char * str, ... )
|
||||||
|
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
||||||
if(logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
outTimestamp(logfile);
|
outTimestamp(logfile);
|
||||||
|
|
||||||
|
|
@ -766,11 +787,12 @@ void Log::outMenu( const char * str, ... )
|
||||||
|
|
||||||
void Log::outRALog( const char * str, ... )
|
void Log::outRALog( const char * str, ... )
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
va_list ap;
|
|
||||||
if (raLogfile)
|
if (raLogfile)
|
||||||
{
|
{
|
||||||
|
va_list ap;
|
||||||
outTimestamp(raLogfile);
|
outTimestamp(raLogfile);
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
vfprintf(raLogfile, str, ap);
|
vfprintf(raLogfile, str, ap);
|
||||||
|
|
@ -778,12 +800,13 @@ void Log::outRALog( const char * str, ... )
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fflush(raLogfile);
|
fflush(raLogfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void outstring_log(const char * str, ...)
|
void outstring_log(const char * str, ...)
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
@ -797,7 +820,7 @@ void outstring_log(const char * str, ...)
|
||||||
|
|
||||||
void detail_log(const char * str, ...)
|
void detail_log(const char * str, ...)
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
@ -811,7 +834,7 @@ void detail_log(const char * str, ...)
|
||||||
|
|
||||||
void debug_log(const char * str, ...)
|
void debug_log(const char * str, ...)
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
@ -825,7 +848,7 @@ void debug_log(const char * str, ...)
|
||||||
|
|
||||||
void error_log(const char * str, ...)
|
void error_log(const char * str, ...)
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
@ -839,7 +862,7 @@ void error_log(const char * str, ...)
|
||||||
|
|
||||||
void error_db_log(const char * str, ...)
|
void error_db_log(const char * str, ...)
|
||||||
{
|
{
|
||||||
if( !str )
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,21 @@
|
||||||
class Config;
|
class Config;
|
||||||
class ByteBuffer;
|
class ByteBuffer;
|
||||||
|
|
||||||
|
enum LogLevel
|
||||||
|
{
|
||||||
|
LOG_LVL_MINIMAL = 0, // unconditional and errors
|
||||||
|
LOG_LVL_BASIC = 1,
|
||||||
|
LOG_LVL_DETAIL = 2,
|
||||||
|
LOG_LVL_DEBUG = 3
|
||||||
|
};
|
||||||
|
|
||||||
// bitmask
|
// bitmask
|
||||||
enum LogFilters
|
enum LogFilters
|
||||||
{
|
{
|
||||||
LOG_FILTER_TRANSPORT_MOVES = 1,
|
LOG_FILTER_TRANSPORT_MOVES = 0x01,
|
||||||
LOG_FILTER_CREATURE_MOVES = 2,
|
LOG_FILTER_CREATURE_MOVES = 0x02,
|
||||||
LOG_FILTER_VISIBILITY_CHANGES = 4,
|
LOG_FILTER_VISIBILITY_CHANGES = 0x04,
|
||||||
LOG_FILTER_ACHIEVEMENT_UPDATES= 8
|
LOG_FILTER_ACHIEVEMENT_UPDATES= 0x08
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Color
|
enum Color
|
||||||
|
|
@ -123,7 +131,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
|
||||||
static void outTimestamp(FILE* file);
|
static void outTimestamp(FILE* file);
|
||||||
static std::string GetTimestampStr();
|
static std::string GetTimestampStr();
|
||||||
uint32 getLogFilter() const { return m_logFilter; }
|
uint32 getLogFilter() const { return m_logFilter; }
|
||||||
bool IsOutDebug() const { return m_logLevel > 2 || (m_logFileLevel > 2 && logfile); }
|
bool HasLogLevelOrHigher(LogLevel loglvl) const { return m_logLevel >= loglvl || (m_logFileLevel >= loglvl && logfile); }
|
||||||
bool IsOutCharDump() const { return m_charLog_Dump; }
|
bool IsOutCharDump() const { return m_charLog_Dump; }
|
||||||
bool IsIncludeTime() const { return m_includeTime; }
|
bool IsIncludeTime() const { return m_includeTime; }
|
||||||
private:
|
private:
|
||||||
|
|
@ -138,8 +146,8 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
|
||||||
FILE* worldLogfile;
|
FILE* worldLogfile;
|
||||||
|
|
||||||
// log/console control
|
// log/console control
|
||||||
uint32 m_logLevel;
|
LogLevel m_logLevel;
|
||||||
uint32 m_logFileLevel;
|
LogLevel m_logFileLevel;
|
||||||
bool m_colored;
|
bool m_colored;
|
||||||
bool m_includeTime;
|
bool m_includeTime;
|
||||||
Color m_colors[4];
|
Color m_colors[4];
|
||||||
|
|
@ -159,11 +167,14 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
|
||||||
|
|
||||||
#define sLog MaNGOS::Singleton<Log>::Instance()
|
#define sLog MaNGOS::Singleton<Log>::Instance()
|
||||||
|
|
||||||
#ifdef MANGOS_DEBUG
|
#define BASIC_LOG(...) if (sLog.HasLogLevelOrHigher(LOG_LVL_BASIC)) sLog.outBasic(__VA_ARGS__)
|
||||||
#define DEBUG_LOG sLog.outDebug
|
#define BASIC_FILTER_LOG(F,...) if (sLog.HasLogLevelOrHigher(LOG_LVL_BASIC) && (sLog.getLogFilter() & (F))==0) sLog.outBasic(__VA_ARGS__)
|
||||||
#else
|
|
||||||
#define DEBUG_LOG
|
#define DETAIL_LOG(...) if (sLog.HasLogLevelOrHigher(LOG_LVL_DETAIL)) sLog.outDebug(__VA_ARGS__)
|
||||||
#endif
|
#define DETAIL_FILTER_LOG(F,...) if (sLog.HasLogLevelOrHigher(LOG_LVL_DETAIL) && (sLog.getLogFilter() & (F))==0) sLog.outDetail(__VA_ARGS__)
|
||||||
|
|
||||||
|
#define DEBUG_LOG(...) if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) sLog.outDebug( __VA_ARGS__)
|
||||||
|
#define DEBUG_FILTER_LOG(F,...) if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG) && (sLog.getLogFilter() & (F))==0) sLog.outDetail(__VA_ARGS__)
|
||||||
|
|
||||||
// primary for script library
|
// primary for script library
|
||||||
void MANGOS_DLL_SPEC outstring_log(const char * str, ...) ATTR_PRINTF(1,2);
|
void MANGOS_DLL_SPEC outstring_log(const char * str, ...) ATTR_PRINTF(1,2);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9835"
|
#define REVISION_NR "9836"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue