*Fix the format of world log.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-25 08:59:18 -05:00
parent a72f23f56b
commit 28359b3ea8
3 changed files with 35 additions and 5 deletions

View File

@@ -65,6 +65,34 @@ void WorldLog::Initialize()
m_dbWorld = sConfig.GetBoolDefault("LogDB.World", false); // can be VERY heavy if enabled
}
void WorldLog::outTimestampLog(char const *fmt, ...)
{
if( LogWorld() )
{
Guard guard(*this);
ASSERT(i_file);
Log::outTimestamp(i_file);
va_list args;
va_start(args, fmt);
vfprintf(i_file, fmt, args);
//fprintf(i_file, "\n" );
va_end(args);
fflush(i_file);
}
if (sLog.GetLogDB() && m_dbWorld)
{
va_list ap2;
va_start(ap2, fmt);
char nnew_str[MAX_QUERY_LEN];
vsnprintf(nnew_str, MAX_QUERY_LEN, fmt, ap2);
sLog.outDB(LOG_TYPE_WORLD, nnew_str);
va_end(ap2);
}
}
void WorldLog::outLog(char const *fmt, ...)
{
if( LogWorld() )
@@ -75,7 +103,7 @@ void WorldLog::outLog(char const *fmt, ...)
va_list args;
va_start(args, fmt);
vfprintf(i_file, fmt, args);
fprintf(i_file, "\n" );
//fprintf(i_file, "\n" );
va_end(args);
fflush(i_file);

View File

@@ -49,6 +49,7 @@ class TRINITY_DLL_DECL WorldLog : public Trinity::Singleton<WorldLog, Trinity::C
bool LogWorld(void) const { return (i_file != NULL); }
/// %Log to the file
void outLog(char const *fmt, ...);
void outTimestampLog(char const *fmt, ...);
private:
FILE *i_file;

View File

@@ -169,7 +169,7 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
// Dump outgoing packet.
if (sWorldLog.LogWorld ())
{
sWorldLog.outLog ("SERVER:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
sWorldLog.outTimestampLog ("SERVER:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
(uint32) get_handle (),
pct.size (),
LookupOpcodeName (pct.GetOpcode ()),
@@ -181,8 +181,9 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
for (uint32 j = 0; j < 16 && p < pct.size (); j++)
sWorldLog.outLog ("%.2X ", const_cast<WorldPacket&>(pct)[p++]);
sWorldLog.outLog ("");
sWorldLog.outLog ("\n");
}
sWorldLog.outLog ("\n");
}
ServerPktHeader header(pct.size()+2, pct.GetOpcode());
@@ -678,7 +679,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
// Dump received packet.
if (sWorldLog.LogWorld ())
{
sWorldLog.outLog ("CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
sWorldLog.outTimestampLog ("CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
(uint32) get_handle (),
new_pct->size (),
LookupOpcodeName (new_pct->GetOpcode ()),
@@ -690,7 +691,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
for (uint32 j = 0; j < 16 && p < new_pct->size (); j++)
sWorldLog.outLog ("%.2X ", (*new_pct)[p++]);
sWorldLog.outLog ("");
sWorldLog.outLog ("\n");
}
}