[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:
VladimirMangos 2010-05-04 20:59:50 +04:00
parent 6726a08b48
commit 6dec6c8a9f
12 changed files with 168 additions and 179 deletions

View file

@ -616,10 +616,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
if(GetPlayer()->GetSession()->PlayerLoading())
return;
#ifdef MANGOS_DEBUG
if((sLog.getLogFilter() & LOG_FILTER_ACHIEVEMENT_UPDATES)==0)
sLog.outDebug("AchievementMgr::SendAchievementEarned(%u)", achievement->ID);
#endif
DEBUG_FILTER_LOG(LOG_FILTER_ACHIEVEMENT_UPDATES, "AchievementMgr::SendAchievementEarned(%u)", achievement->ID);
if(Guild* guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()))
{

View file

@ -65,10 +65,7 @@ VisibleNotifier::Notify()
{
i_player.m_clientGUIDs.erase(*itr);
#ifdef MANGOS_DEBUG
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
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());
}
// send update to other players (except player updates that already sent using SendUpdateToPlayer)

View file

@ -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
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
{
#ifdef MANGOS_DEBUG
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
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());
// do move or do move to respawn or remove creature if previous all fail
if(CreatureCellRelocation(creature,new_cell))
@ -885,10 +882,7 @@ Map::CreatureRelocation(Creature *creature, float x, float y, float z, float ang
if(!CreatureRespawnRelocation(creature))
{
// ... or unload (if respawn grid also not loaded)
#ifdef MANGOS_DEBUG
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
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",creature->GetGUIDLow(),creature->GetEntry());
creature->SetNeedNotify();
}
}
@ -910,10 +904,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
// if in same cell then none do
if(old_cell.DiffCell(new_cell))
{
#ifdef MANGOS_DEBUG
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
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( !old_cell.DiffGrid(new_cell) )
{
@ -924,10 +915,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
}
else
{
#ifdef MANGOS_DEBUG
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
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());
}
return true;
@ -938,10 +926,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell)
{
EnsureGridLoadedAtEnter(new_cell);
#ifdef MANGOS_DEBUG
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
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());
RemoveFromGrid(c,getNGrid(old_cell.GridX(), old_cell.GridY()),old_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
if(loaded(GridPair(new_cell.GridX(), new_cell.GridY())))
{
#ifdef MANGOS_DEBUG
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
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());
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
#ifdef MANGOS_DEBUG
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
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());
return false;
}
@ -985,10 +964,7 @@ bool Map::CreatureRespawnRelocation(Creature *c)
c->CombatStop();
c->GetMotionMaster()->Clear();
#ifdef MANGOS_DEBUG
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
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());
// teleport it to respawn point (like normal respawn if player see)
if(CreatureCellRelocation(c,resp_cell))

View file

@ -17132,7 +17132,7 @@ void Player::_SaveStats()
void Player::outDebugValues() const
{
if(!sLog.IsOutDebug()) // optimize disabled debug output
if(!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
return;
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);
m_clientGUIDs.insert(i_guid);
#ifdef MANGOS_DEBUG
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
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));
// target aura duration for caster show only if target exist at caster 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);
m_clientGUIDs.erase(t_guid);
#ifdef MANGOS_DEBUG
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
DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s out of range for player %u. Distance = %f",t_guid.GetString().c_str(),GetGUIDLow(),GetDistance(target));
}
}
else
@ -19159,10 +19153,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe
if(target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport())
m_clientGUIDs.insert(target->GetObjectGuid());
#ifdef MANGOS_DEBUG
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
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));
// target aura duration for caster show only if target exist at caster 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);
m_clientGUIDs.erase(t_guid);
#ifdef MANGOS_DEBUG
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
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));
}
}
else
@ -19216,10 +19204,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD
target->BuildCreateUpdateBlockForPlayer(&data, this);
UpdateVisibilityOf_helper(m_clientGUIDs,target);
#ifdef MANGOS_DEBUG
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
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));
}
}
}

View file

@ -566,7 +566,7 @@ void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure
{
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);
}
}

View file

@ -186,7 +186,7 @@ bool WorldSession::Update(uint32 /*diff*/)
else if(_player->IsInWorld())
{
(this->*opHandle.handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
LogUnprocessedTail(packet);
}
// 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
(this->*opHandle.handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
LogUnprocessedTail(packet);
}
break;
@ -212,7 +212,7 @@ bool WorldSession::Update(uint32 /*diff*/)
else
{
(this->*opHandle.handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
LogUnprocessedTail(packet);
}
break;
@ -230,7 +230,7 @@ bool WorldSession::Update(uint32 /*diff*/)
m_playerRecentlyLogout = false;
(this->*opHandle.handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
LogUnprocessedTail(packet);
break;
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.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if(sLog.IsOutDebug())
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
sLog.outDebug("Dumping error causing packet:");
packet->hexlike();

View file

@ -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.",
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:");
new_pct->hexlike();

View file

@ -278,7 +278,7 @@ WorldSocketMgr::StartNetwork (ACE_UINT16 port, std::string& address)
m_addr = address;
m_port = port;
if (!sLog.IsOutDebug ())
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
ACE_Log_Msg::instance ()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS);
if (StartReactiveIO (port, address.c_str()) == -1)

View file

@ -412,7 +412,7 @@ class ByteBuffer
void print_storage() const
{
if(!sLog.IsOutDebug()) // optimize disabled debug output
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
return;
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
@ -423,7 +423,7 @@ class ByteBuffer
void textlike() const
{
if(!sLog.IsOutDebug()) // optimize disabled debug output
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
return;
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
@ -434,7 +434,7 @@ class ByteBuffer
void hexlike() const
{
if(!sLog.IsOutDebug()) // optimize disabled debug output
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
return;
uint32 j = 1, k = 1;

View file

@ -159,22 +159,30 @@ void Log::ResetColor(bool stdout_stream)
#endif
}
void Log::SetLogLevel(char *Level)
void Log::SetLogLevel(char* level)
{
int32 NewLevel =atoi((char*)Level);
if ( NewLevel <0 )
NewLevel = 0;
m_logLevel = NewLevel;
int32 newLevel =atoi((char*)level);
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);
if ( NewLevel <0 )
NewLevel = 0;
m_logFileLevel = NewLevel;
int32 newLevel =atoi((char*)level);
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);
}
@ -232,8 +240,8 @@ void Log::Initialize()
// Main log file settings
m_includeTime = sConfig.GetBoolDefault("LogTime", false);
m_logLevel = sConfig.GetIntDefault("LogLevel", 0);
m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
m_logLevel = LogLevel(sConfig.GetIntDefault("LogLevel", 0));
m_logFileLevel = LogLevel(sConfig.GetIntDefault("LogFileLevel", 0));
InitColors(sConfig.GetStringDefault("LogColors", ""));
m_logFilter = 0;
@ -356,6 +364,7 @@ void Log::outString()
fprintf(logfile, "\n" );
fflush(logfile);
}
fflush(stdout);
}
@ -380,6 +389,7 @@ void Log::outString( const char * str, ... )
ResetColor(true);
printf( "\n" );
if (logfile)
{
outTimestamp(logfile);
@ -391,6 +401,7 @@ void Log::outString( const char * str, ... )
fflush(logfile);
}
fflush(stdout);
}
@ -427,6 +438,7 @@ void Log::outError( const char * err, ... )
fprintf(logfile, "\n" );
fflush(logfile);
}
fflush(stderr);
}
@ -477,6 +489,7 @@ void Log::outErrorDb( const char * err, ... )
fprintf(dberLogfile, "\n" );
fflush(dberLogfile);
}
fflush(stderr);
}
@ -485,7 +498,7 @@ void Log::outBasic( const char * str, ... )
if (!str)
return;
if( m_logLevel > 0 )
if (m_logLevel >= LOG_LVL_BASIC)
{
if (m_colored)
SetColor(true,m_colors[LogDetails]);
@ -504,7 +517,7 @@ void Log::outBasic( const char * str, ... )
printf( "\n" );
}
if(logfile && m_logFileLevel > 0)
if (logfile && m_logFileLevel >= LOG_LVL_BASIC)
{
va_list ap;
outTimestamp(logfile);
@ -514,6 +527,7 @@ void Log::outBasic( const char * str, ... )
va_end(ap);
fflush(logfile);
}
fflush(stdout);
}
@ -522,7 +536,7 @@ void Log::outDetail( const char * str, ... )
if (!str)
return;
if( m_logLevel > 1 )
if (m_logLevel >= LOG_LVL_DETAIL)
{
if (m_colored)
@ -541,7 +555,8 @@ void Log::outDetail( const char * str, ... )
printf( "\n" );
}
if(logfile && m_logFileLevel > 1)
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
{
outTimestamp(logfile);
@ -561,7 +576,8 @@ void Log::outDebugInLine( const char * str, ... )
{
if (!str)
return;
if( m_logLevel > 2 )
if (m_logLevel >= LOG_LVL_DEBUG)
{
if (m_colored)
SetColor(true,m_colors[LogDebug]);
@ -574,7 +590,8 @@ void Log::outDebugInLine( const char * str, ... )
if (m_colored)
ResetColor(true);
}
if(logfile && m_logFileLevel > 2)
if (logfile && m_logFileLevel >= LOG_LVL_DEBUG)
{
va_list ap;
va_start(ap, str);
@ -587,7 +604,8 @@ void Log::outDebug( const char * str, ... )
{
if (!str)
return;
if( m_logLevel > 2 )
if (m_logLevel >= LOG_LVL_DEBUG)
{
if (m_colored)
SetColor(true,m_colors[LogDebug]);
@ -605,7 +623,8 @@ void Log::outDebug( const char * str, ... )
printf( "\n" );
}
if(logfile && m_logFileLevel > 2)
if (logfile && m_logFileLevel >= LOG_LVL_DEBUG)
{
outTimestamp(logfile);
@ -617,6 +636,7 @@ void Log::outDebug( const char * str, ... )
fprintf(logfile, "\n" );
fflush(logfile);
}
fflush(stdout);
}
@ -625,7 +645,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
if (!str)
return;
if( m_logLevel > 1 )
if (m_logLevel >= LOG_LVL_DETAIL)
{
if (m_colored)
SetColor(true,m_colors[LogDetails]);
@ -643,7 +663,8 @@ void Log::outCommand( uint32 account, const char * str, ... )
printf( "\n" );
}
if(logfile && m_logFileLevel > 1)
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
{
va_list ap;
outTimestamp(logfile);
@ -768,9 +789,10 @@ void Log::outRALog( const char * str, ... )
{
if (!str)
return;
va_list ap;
if (raLogfile)
{
va_list ap;
outTimestamp(raLogfile);
va_start(ap, str);
vfprintf(raLogfile, str, ap);
@ -778,6 +800,7 @@ void Log::outRALog( const char * str, ... )
va_end(ap);
fflush(raLogfile);
}
fflush(stdout);
}

View file

@ -25,13 +25,21 @@
class Config;
class ByteBuffer;
enum LogLevel
{
LOG_LVL_MINIMAL = 0, // unconditional and errors
LOG_LVL_BASIC = 1,
LOG_LVL_DETAIL = 2,
LOG_LVL_DEBUG = 3
};
// bitmask
enum LogFilters
{
LOG_FILTER_TRANSPORT_MOVES = 1,
LOG_FILTER_CREATURE_MOVES = 2,
LOG_FILTER_VISIBILITY_CHANGES = 4,
LOG_FILTER_ACHIEVEMENT_UPDATES= 8
LOG_FILTER_TRANSPORT_MOVES = 0x01,
LOG_FILTER_CREATURE_MOVES = 0x02,
LOG_FILTER_VISIBILITY_CHANGES = 0x04,
LOG_FILTER_ACHIEVEMENT_UPDATES= 0x08
};
enum Color
@ -123,7 +131,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
static void outTimestamp(FILE* file);
static std::string GetTimestampStr();
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 IsIncludeTime() const { return m_includeTime; }
private:
@ -138,8 +146,8 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
FILE* worldLogfile;
// log/console control
uint32 m_logLevel;
uint32 m_logFileLevel;
LogLevel m_logLevel;
LogLevel m_logFileLevel;
bool m_colored;
bool m_includeTime;
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()
#ifdef MANGOS_DEBUG
#define DEBUG_LOG sLog.outDebug
#else
#define DEBUG_LOG
#endif
#define BASIC_LOG(...) if (sLog.HasLogLevelOrHigher(LOG_LVL_BASIC)) sLog.outBasic(__VA_ARGS__)
#define BASIC_FILTER_LOG(F,...) if (sLog.HasLogLevelOrHigher(LOG_LVL_BASIC) && (sLog.getLogFilter() & (F))==0) sLog.outBasic(__VA_ARGS__)
#define DETAIL_LOG(...) if (sLog.HasLogLevelOrHigher(LOG_LVL_DETAIL)) sLog.outDebug(__VA_ARGS__)
#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
void MANGOS_DLL_SPEC outstring_log(const char * str, ...) ATTR_PRINTF(1,2);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9835"
#define REVISION_NR "9836"
#endif // __REVISION_NR_H__