mirror of
https://github.com/mangosfour/server.git
synced 2025-12-26 16:37:06 +00:00
[6848] Implement possibility creating gm log per account files using new option in mangosd.conf. Releated cleanups.
This commit is contained in:
parent
d34899097f
commit
4ccfa1e71e
11 changed files with 145 additions and 80 deletions
|
|
@ -276,7 +276,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
|||
|
||||
if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
|
||||
{
|
||||
sLog.outCommand("GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
|
||||
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
|
||||
GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -755,7 +755,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, st
|
|||
{
|
||||
Player* p = m_session->GetPlayer();
|
||||
uint64 sel_guid = p->GetSelection();
|
||||
sLog.outCommand("Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s (GUID: %u)]",
|
||||
sLog.outCommand(m_session->GetAccountId(),"Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s (GUID: %u)]",
|
||||
fullcmd.c_str(),p->GetName(),m_session->GetAccountId(),p->GetPositionX(),p->GetPositionY(),p->GetPositionZ(),p->GetMapId(),
|
||||
GetLogNameForGuid(sel_guid),GUID_LOPART(sel_guid));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -984,7 +984,7 @@ void WorldSession::HandleGuildBankDeposit( WorldPacket & recv_data )
|
|||
// logging money
|
||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
{
|
||||
sLog.outCommand("GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)",
|
||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)",
|
||||
_player->GetName(),_player->GetSession()->GetAccountId(),money,GuildId);
|
||||
}
|
||||
|
||||
|
|
@ -1378,7 +1378,7 @@ void WorldSession::HandleGuildBankDepositItem( WorldPacket & recv_data )
|
|||
// logging item move to bank
|
||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
{
|
||||
sLog.outCommand("GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
||||
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
||||
GuildId);
|
||||
|
|
@ -1447,7 +1447,7 @@ void WorldSession::HandleGuildBankDepositItem( WorldPacket & recv_data )
|
|||
// logging item move to bank (before items merge
|
||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
{
|
||||
sLog.outCommand("GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
||||
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),SplitedAmount,GuildId);
|
||||
}
|
||||
|
|
@ -1473,7 +1473,7 @@ void WorldSession::HandleGuildBankDepositItem( WorldPacket & recv_data )
|
|||
// logging item move to bank
|
||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
{
|
||||
sLog.outCommand("GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
||||
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
||||
GuildId);
|
||||
|
|
@ -1523,7 +1523,7 @@ void WorldSession::HandleGuildBankDepositItem( WorldPacket & recv_data )
|
|||
// logging item move to bank
|
||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
{
|
||||
sLog.outCommand("GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
||||
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
||||
GuildId);
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
|||
|
||||
if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
|
||||
{
|
||||
sLog.outCommand("GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
|
||||
sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail item: %s (Entry: %u Count: %u) to player: %s (Account: %u)",
|
||||
GetPlayerName(), GetAccountId(), mailItem.item->GetProto()->Name1, mailItem.item->GetEntry(), mailItem.item->GetCount(), receiver.c_str(), rc_account);
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +249,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
|
|||
|
||||
if(money > 0 && GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
{
|
||||
sLog.outCommand("GM %s (Account: %u) mail money: %u to player: %s (Account: %u)",
|
||||
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) mail money: %u to player: %s (Account: %u)",
|
||||
GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account);
|
||||
}
|
||||
}
|
||||
|
|
@ -458,7 +458,7 @@ void WorldSession::HandleTakeItem(WorldPacket & recv_data )
|
|||
if(!objmgr.GetPlayerNameByGUID(sender_guid,sender_name))
|
||||
sender_name = objmgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
|
||||
}
|
||||
sLog.outCommand("GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
|
||||
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) receive mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)",
|
||||
GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount(),m->COD,sender_name.c_str(),sender_accId);
|
||||
}
|
||||
else if(!receive)
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction )
|
|||
|
||||
uint32 owner_accid = GetPlayerAccountIdByGUID(auction->owner);
|
||||
|
||||
sLog.outCommand("GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
|
||||
sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
|
||||
bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3728,10 +3728,12 @@ void Spell::EffectEnchantItemPerm(uint32 i)
|
|||
return;
|
||||
|
||||
if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
|
||||
sLog.outCommand("GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
|
||||
{
|
||||
sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
|
||||
p_caster->GetName(),p_caster->GetSession()->GetAccountId(),
|
||||
itemTarget->GetProto()->Name1,itemTarget->GetEntry(),
|
||||
item_owner->GetName(),item_owner->GetSession()->GetAccountId());
|
||||
}
|
||||
|
||||
// remove old enchanting before applying new if equipped
|
||||
item_owner->ApplyEnchantment(itemTarget,PERM_ENCHANTMENT_SLOT,false);
|
||||
|
|
@ -3857,10 +3859,12 @@ void Spell::EffectEnchantItemTmp(uint32 i)
|
|||
return;
|
||||
|
||||
if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
|
||||
sLog.outCommand("GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
|
||||
{
|
||||
sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
|
||||
p_caster->GetName(),p_caster->GetSession()->GetAccountId(),
|
||||
itemTarget->GetProto()->Name1,itemTarget->GetEntry(),
|
||||
item_owner->GetName(),item_owner->GetSession()->GetAccountId());
|
||||
}
|
||||
|
||||
// remove old enchanting before applying new if equipped
|
||||
item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT,false);
|
||||
|
|
|
|||
|
|
@ -193,10 +193,12 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
|
|||
// logging
|
||||
sLog.outDebug("partner storing: %u",myItems[i]->GetGUIDLow());
|
||||
if( _player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
|
||||
sLog.outCommand("GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
|
||||
{
|
||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
|
||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
||||
myItems[i]->GetProto()->Name1,myItems[i]->GetEntry(),myItems[i]->GetCount(),
|
||||
_player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId());
|
||||
}
|
||||
|
||||
// store
|
||||
_player->pTrader->MoveItemToInventory( traderDst, myItems[i], true, true);
|
||||
|
|
@ -206,10 +208,12 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
|
|||
// logging
|
||||
sLog.outDebug("player storing: %u",hisItems[i]->GetGUIDLow());
|
||||
if( _player->pTrader->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
|
||||
sLog.outCommand("GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
|
||||
{
|
||||
sLog.outCommand(_player->pTrader->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
|
||||
_player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId(),
|
||||
hisItems[i]->GetProto()->Name1,hisItems[i]->GetEntry(),hisItems[i]->GetCount(),
|
||||
_player->GetName(),_player->GetSession()->GetAccountId());
|
||||
}
|
||||
|
||||
// store
|
||||
_player->MoveItemToInventory( playerDst, hisItems[i], true, true);
|
||||
|
|
@ -376,15 +380,19 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
|
|||
if(sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
{
|
||||
if( _player->GetSession()->GetSecurity() > SEC_PLAYER && _player->tradeGold > 0)
|
||||
sLog.outCommand("GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)",
|
||||
{
|
||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)",
|
||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
||||
_player->tradeGold,
|
||||
_player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId());
|
||||
}
|
||||
if( _player->pTrader->GetSession()->GetSecurity() > SEC_PLAYER && _player->pTrader->tradeGold > 0)
|
||||
sLog.outCommand("GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)",
|
||||
{
|
||||
sLog.outCommand(_player->pTrader->GetSession()->GetAccountId(),"GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)",
|
||||
_player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId(),
|
||||
_player->pTrader->tradeGold,
|
||||
_player->GetName(),_player->GetSession()->GetAccountId());
|
||||
}
|
||||
}
|
||||
|
||||
// update money
|
||||
|
|
|
|||
|
|
@ -252,14 +252,21 @@ AddonChannel = 1
|
|||
# 1 - include dumping chars to log
|
||||
#
|
||||
# GmLogFile
|
||||
# Log file of gm commands
|
||||
# GM Log file of gm commands
|
||||
# Default: "" (Disable)
|
||||
#
|
||||
# GmLogTimestamp
|
||||
# Logfile with timestamp of server start in name
|
||||
# GM Logfile with timestamp of server start in name
|
||||
# Default: 0 - no timestamp in name
|
||||
# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext
|
||||
#
|
||||
# GmLogPerAccount
|
||||
# GM Logfiles with GM account id (Note: logs not created if GmLogFile not set)
|
||||
# Default: 0 - add gm log data to single log file
|
||||
# 1 - add gm log data to account specific log files with name
|
||||
# in form Logname_#ID_YYYY-MM-DD_HH-MM-SS.Ext
|
||||
# or form Logname_#ID.Ext
|
||||
#
|
||||
# RaLogFile
|
||||
# Log file of RA commands
|
||||
# Default: "Ra.log"
|
||||
|
|
@ -291,6 +298,7 @@ CharLogTimestamp = 0
|
|||
CharLogDump = 0
|
||||
GmLogFile = ""
|
||||
GmLogTimestamp = 0
|
||||
GmLogPerAccount = 0
|
||||
RaLogFile = ""
|
||||
LogColors = ""
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,13 @@ enum LogType
|
|||
|
||||
const int LogType_count = int(LogError) +1;
|
||||
|
||||
Log::Log() :
|
||||
raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
|
||||
dberLogfile(NULL), m_colored(false), m_includeTime(false), m_gmlog_per_account(false)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void Log::InitColors(std::string str)
|
||||
{
|
||||
if(str.empty())
|
||||
|
|
@ -173,73 +180,56 @@ void Log::SetLogFileLevel(char *Level)
|
|||
|
||||
void Log::Initialize()
|
||||
{
|
||||
std::string logsDir = sConfig.GetStringDefault("LogsDir","");
|
||||
|
||||
if(!logsDir.empty())
|
||||
/// Common log files data
|
||||
m_logsDir = sConfig.GetStringDefault("LogsDir","");
|
||||
if(!m_logsDir.empty())
|
||||
{
|
||||
if((logsDir.at(logsDir.length()-1)!='/') && (logsDir.at(logsDir.length()-1)!='\\'))
|
||||
logsDir.append("/");
|
||||
if((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
|
||||
m_logsDir.append("/");
|
||||
}
|
||||
|
||||
std::string logfn=sConfig.GetStringDefault("LogFile", "");
|
||||
if(!logfn.empty())
|
||||
m_logsTimestamp = "_" + GetTimestampStr();
|
||||
|
||||
/// Open specific log files
|
||||
logfile = openLogFile("LogFile","LogTimestamp","w");
|
||||
|
||||
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
|
||||
if(!m_gmlog_per_account)
|
||||
gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
|
||||
else
|
||||
{
|
||||
if(sConfig.GetBoolDefault("LogTimestamp",false))
|
||||
// GM log settings for per account case
|
||||
m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", "");
|
||||
if(!m_gmlog_filename_format.empty())
|
||||
{
|
||||
std::string logTimestamp = GetTimestampStr();
|
||||
logTimestamp.insert(0,"_");
|
||||
size_t dot_pos = logfn.find_last_of(".");
|
||||
if(dot_pos!=logfn.npos)
|
||||
logfn.insert(dot_pos,logTimestamp);
|
||||
bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp",false);
|
||||
|
||||
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
|
||||
if(dot_pos!=m_gmlog_filename_format.npos)
|
||||
{
|
||||
if(m_gmlog_timestamp)
|
||||
m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);
|
||||
|
||||
m_gmlog_filename_format.insert(dot_pos,"_#%u");
|
||||
}
|
||||
else
|
||||
logfn += logTimestamp;
|
||||
{
|
||||
m_gmlog_filename_format += "_#%u";
|
||||
|
||||
if(m_gmlog_timestamp)
|
||||
m_gmlog_filename_format += m_logsTimestamp;
|
||||
}
|
||||
|
||||
m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
|
||||
}
|
||||
|
||||
logfile = fopen((logsDir+logfn).c_str(), "w");
|
||||
}
|
||||
|
||||
std::string gmlogname = sConfig.GetStringDefault("GMLogFile", "");
|
||||
if(!gmlogname.empty())
|
||||
{
|
||||
if(sConfig.GetBoolDefault("GmLogTimestamp",false))
|
||||
{
|
||||
std::string gmLogTimestamp = GetTimestampStr();
|
||||
gmLogTimestamp.insert(0,"_");
|
||||
size_t dot_pos = gmlogname.find_last_of(".");
|
||||
if(dot_pos!=gmlogname.npos)
|
||||
gmlogname.insert(dot_pos,gmLogTimestamp);
|
||||
else
|
||||
gmlogname += gmLogTimestamp;
|
||||
}
|
||||
gmLogfile = fopen((logsDir+gmlogname).c_str(), "a");
|
||||
}
|
||||
charLogfile = openLogFile("CharLogFile","CharLogTimestamp","a");
|
||||
|
||||
std::string charlogname = sConfig.GetStringDefault("CharLogFile", "");
|
||||
if(!charlogname.empty())
|
||||
{
|
||||
if(sConfig.GetBoolDefault("CharLogTimestamp",false))
|
||||
{
|
||||
std::string charLogTimestamp = GetTimestampStr();
|
||||
charLogTimestamp.insert(0,"_");
|
||||
size_t dot_pos = charlogname.find_last_of(".");
|
||||
if(dot_pos!=charlogname.npos)
|
||||
charlogname.insert(dot_pos,charLogTimestamp);
|
||||
else
|
||||
charlogname += charLogTimestamp;
|
||||
}
|
||||
charLogfile = fopen((logsDir+charlogname).c_str(), "a");
|
||||
}
|
||||
dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
|
||||
raLogfile = openLogFile("RaLogFile",NULL,"a");
|
||||
|
||||
std::string dberlogname = sConfig.GetStringDefault("DBErrorLogFile", "");
|
||||
if(!dberlogname.empty())
|
||||
{
|
||||
dberLogfile = fopen((logsDir+dberlogname).c_str(), "a");
|
||||
}
|
||||
std::string ralogname = sConfig.GetStringDefault("RaLogFile", "");
|
||||
if(!ralogname.empty())
|
||||
{
|
||||
raLogfile = fopen((logsDir+ralogname).c_str(), "a");
|
||||
}
|
||||
// Main log file settings
|
||||
m_includeTime = sConfig.GetBoolDefault("LogTime", false);
|
||||
m_logLevel = sConfig.GetIntDefault("LogLevel", 0);
|
||||
m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
|
||||
|
|
@ -254,9 +244,38 @@ void Log::Initialize()
|
|||
if(sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
|
||||
m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
|
||||
|
||||
// Char log settings
|
||||
m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false);
|
||||
}
|
||||
|
||||
FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode)
|
||||
{
|
||||
std::string logfn=sConfig.GetStringDefault(configFileName, "");
|
||||
if(logfn.empty())
|
||||
return NULL;
|
||||
|
||||
if(configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag,false))
|
||||
{
|
||||
size_t dot_pos = logfn.find_last_of(".");
|
||||
if(dot_pos!=logfn.npos)
|
||||
logfn.insert(dot_pos,m_logsTimestamp);
|
||||
else
|
||||
logfn += m_logsTimestamp;
|
||||
}
|
||||
|
||||
return fopen((m_logsDir+logfn).c_str(), mode);
|
||||
}
|
||||
|
||||
FILE* Log::openGmlogPerAccount(uint32 account)
|
||||
{
|
||||
if(m_gmlog_filename_format.empty())
|
||||
return NULL;
|
||||
|
||||
char namebuf[MAX_PATH];
|
||||
snprintf(namebuf,MAX_PATH,m_gmlog_filename_format.c_str(),account);
|
||||
return fopen(namebuf, "a");
|
||||
}
|
||||
|
||||
void Log::outTimestamp(FILE* file)
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
|
|
@ -575,7 +594,7 @@ void Log::outDebug( const char * str, ... )
|
|||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outCommand( const char * str, ... )
|
||||
void Log::outCommand( uint32 account, const char * str, ... )
|
||||
{
|
||||
if( !str )
|
||||
return;
|
||||
|
|
@ -605,7 +624,21 @@ void Log::outCommand( const char * str, ... )
|
|||
va_end(ap);
|
||||
fflush(logfile);
|
||||
}
|
||||
if(gmLogfile)
|
||||
|
||||
if (m_gmlog_per_account)
|
||||
{
|
||||
if (FILE* per_file = openGmlogPerAccount (account))
|
||||
{
|
||||
va_list ap;
|
||||
outTimestamp(per_file);
|
||||
va_start(ap, str);
|
||||
vfprintf(per_file, str, ap);
|
||||
fprintf(per_file, "\n" );
|
||||
va_end(ap);
|
||||
fclose(per_file);
|
||||
}
|
||||
}
|
||||
else if (gmLogfile)
|
||||
{
|
||||
va_list ap;
|
||||
outTimestamp(gmLogfile);
|
||||
|
|
@ -615,6 +648,7 @@ void Log::outCommand( const char * str, ... )
|
|||
va_end(ap);
|
||||
fflush(gmLogfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ const int Color_count = int(WHITE)+1;
|
|||
class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThread::FastMutex> >
|
||||
{
|
||||
friend class MaNGOS::OperatorNew<Log>;
|
||||
Log() : raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL), dberLogfile(NULL), m_colored(false) { Initialize(); }
|
||||
Log();
|
||||
|
||||
~Log()
|
||||
{
|
||||
if( logfile != NULL )
|
||||
|
|
@ -83,7 +84,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
|
|||
void Initialize();
|
||||
void InitColors(std::string init_str);
|
||||
void outTitle( const char * str);
|
||||
void outCommand( const char * str, ...) ATTR_PRINTF(2,3);
|
||||
void outCommand( uint32 account, const char * str, ...) ATTR_PRINTF(3,4);
|
||||
void outString(); // any log level
|
||||
// any log level
|
||||
void outString( const char * str, ... ) ATTR_PRINTF(2,3);
|
||||
|
|
@ -118,6 +119,9 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
|
|||
bool IsOutCharDump() const { return m_charLog_Dump; }
|
||||
bool IsIncludeTime() const { return m_includeTime; }
|
||||
private:
|
||||
FILE* openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode);
|
||||
FILE* openGmlogPerAccount(uint32 account);
|
||||
|
||||
FILE* raLogfile;
|
||||
FILE* logfile;
|
||||
FILE* gmLogfile;
|
||||
|
|
@ -132,9 +136,16 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
|
|||
Color m_colors[4];
|
||||
uint32 m_logFilter;
|
||||
|
||||
// cache values for after initilization use (like gm log per account case)
|
||||
std::string m_logsDir;
|
||||
std::string m_logsTimestamp;
|
||||
|
||||
// char log control
|
||||
bool m_charLog_Dump;
|
||||
|
||||
// gm log control
|
||||
bool m_gmlog_per_account;
|
||||
std::string m_gmlog_filename_format;
|
||||
};
|
||||
|
||||
#define sLog MaNGOS::Singleton<Log>::Instance()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "6847"
|
||||
#define REVISION_NR "6848"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue