mirror of
https://github.com/mangosfour/server.git
synced 2025-12-26 07:37:02 +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
|
|
@ -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,13 +434,13 @@ 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;
|
||||
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
|
||||
|
||||
if(sLog.IsIncludeTime())
|
||||
if (sLog.IsIncludeTime())
|
||||
sLog.outDebugInLine(" ");
|
||||
|
||||
for(uint32 i = 0; i < size(); ++i)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ Log::Log() :
|
|||
|
||||
void Log::InitColors(const std::string& str)
|
||||
{
|
||||
if(str.empty())
|
||||
if (str.empty())
|
||||
{
|
||||
m_colored = false;
|
||||
return;
|
||||
|
|
@ -159,33 +159,41 @@ 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);
|
||||
|
||||
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);
|
||||
if ( NewLevel <0 )
|
||||
NewLevel = 0;
|
||||
m_logFileLevel = NewLevel;
|
||||
int32 newLevel =atoi((char*)level);
|
||||
|
||||
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()
|
||||
{
|
||||
/// Common log files data
|
||||
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("/");
|
||||
}
|
||||
|
||||
|
|
@ -195,20 +203,20 @@ void Log::Initialize()
|
|||
logfile = openLogFile("LogFile","LogTimestamp","w");
|
||||
|
||||
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
|
||||
if(!m_gmlog_per_account)
|
||||
if (!m_gmlog_per_account)
|
||||
gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
|
||||
else
|
||||
{
|
||||
// GM log settings for per account case
|
||||
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);
|
||||
|
||||
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,"_#%u");
|
||||
|
|
@ -217,7 +225,7 @@ void Log::Initialize()
|
|||
{
|
||||
m_gmlog_filename_format += "_#%u";
|
||||
|
||||
if(m_gmlog_timestamp)
|
||||
if (m_gmlog_timestamp)
|
||||
m_gmlog_filename_format += m_logsTimestamp;
|
||||
}
|
||||
|
||||
|
|
@ -232,19 +240,19 @@ 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;
|
||||
|
||||
if(sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
|
||||
if (sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
|
||||
m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
|
||||
if(sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
|
||||
if (sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
|
||||
m_logFilter |= LOG_FILTER_CREATURE_MOVES;
|
||||
if(sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
|
||||
if (sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
|
||||
m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
|
||||
if(sConfig.GetBoolDefault("LogFilter_AchievementUpdates", true))
|
||||
if (sConfig.GetBoolDefault("LogFilter_AchievementUpdates", true))
|
||||
m_logFilter |= LOG_FILTER_ACHIEVEMENT_UPDATES;
|
||||
|
||||
// Char log settings
|
||||
|
|
@ -254,13 +262,13 @@ void Log::Initialize()
|
|||
FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode)
|
||||
{
|
||||
std::string logfn=sConfig.GetStringDefault(configFileName, "");
|
||||
if(logfn.empty())
|
||||
if (logfn.empty())
|
||||
return NULL;
|
||||
|
||||
if(configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag,false))
|
||||
if (configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag,false))
|
||||
{
|
||||
size_t dot_pos = logfn.find_last_of(".");
|
||||
if(dot_pos!=logfn.npos)
|
||||
if (dot_pos!=logfn.npos)
|
||||
logfn.insert(dot_pos,m_logsTimestamp);
|
||||
else
|
||||
logfn += m_logsTimestamp;
|
||||
|
|
@ -271,7 +279,7 @@ FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFla
|
|||
|
||||
FILE* Log::openGmlogPerAccount(uint32 account)
|
||||
{
|
||||
if(m_gmlog_filename_format.empty())
|
||||
if (m_gmlog_filename_format.empty())
|
||||
return NULL;
|
||||
|
||||
char namebuf[MANGOS_PATH_MAX];
|
||||
|
|
@ -322,20 +330,20 @@ std::string Log::GetTimestampStr()
|
|||
|
||||
void Log::outTitle( const char * str)
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(true,WHITE);
|
||||
|
||||
// not expected utf8 and then send as-is
|
||||
printf("%s", str);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf("\n");
|
||||
if(logfile)
|
||||
if (logfile)
|
||||
{
|
||||
fprintf(logfile, "%s", str);
|
||||
fprintf(logfile, "\n" );
|
||||
|
|
@ -347,27 +355,28 @@ void Log::outTitle( const char * str)
|
|||
|
||||
void Log::outString()
|
||||
{
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
printf( "\n" );
|
||||
if(logfile)
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
fprintf(logfile, "\n" );
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outString( const char * str, ... )
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogNormal]);
|
||||
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -376,11 +385,12 @@ void Log::outString( const char * str, ... )
|
|||
vutf8printf(stdout, str, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
if(logfile)
|
||||
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
|
||||
|
|
@ -391,18 +401,19 @@ void Log::outString( const char * str, ... )
|
|||
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outError( const char * err, ... )
|
||||
{
|
||||
if( !err )
|
||||
if (!err)
|
||||
return;
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(false,m_colors[LogError]);
|
||||
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -411,11 +422,11 @@ void Log::outError( const char * err, ... )
|
|||
vutf8printf(stderr, err, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(false);
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
if(logfile)
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
fprintf(logfile, "ERROR:" );
|
||||
|
|
@ -427,18 +438,19 @@ void Log::outError( const char * err, ... )
|
|||
fprintf(logfile, "\n" );
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
void Log::outErrorDb( const char * err, ... )
|
||||
{
|
||||
if( !err )
|
||||
if (!err)
|
||||
return;
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(false,m_colors[LogError]);
|
||||
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -447,12 +459,12 @@ void Log::outErrorDb( const char * err, ... )
|
|||
vutf8printf(stderr, err, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(false);
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
if(logfile)
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
fprintf(logfile, "ERROR:" );
|
||||
|
|
@ -465,7 +477,7 @@ void Log::outErrorDb( const char * err, ... )
|
|||
fflush(logfile);
|
||||
}
|
||||
|
||||
if(dberLogfile)
|
||||
if (dberLogfile)
|
||||
{
|
||||
outTimestamp(dberLogfile);
|
||||
|
||||
|
|
@ -477,20 +489,21 @@ void Log::outErrorDb( const char * err, ... )
|
|||
fprintf(dberLogfile, "\n" );
|
||||
fflush(dberLogfile);
|
||||
}
|
||||
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
void Log::outBasic( const char * str, ... )
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
if( m_logLevel > 0 )
|
||||
if (m_logLevel >= LOG_LVL_BASIC)
|
||||
{
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDetails]);
|
||||
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -498,13 +511,13 @@ void Log::outBasic( const char * str, ... )
|
|||
vutf8printf(stdout, str, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
if(logfile && m_logFileLevel > 0)
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_BASIC)
|
||||
{
|
||||
va_list ap;
|
||||
outTimestamp(logfile);
|
||||
|
|
@ -514,21 +527,22 @@ void Log::outBasic( const char * str, ... )
|
|||
va_end(ap);
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outDetail( const char * str, ... )
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
if( m_logLevel > 1 )
|
||||
if (m_logLevel >= LOG_LVL_DETAIL)
|
||||
{
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDetails]);
|
||||
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -536,12 +550,13 @@ void Log::outDetail( const char * str, ... )
|
|||
vutf8printf(stdout, str, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
if(logfile && m_logFileLevel > 1)
|
||||
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
|
||||
|
|
@ -559,11 +574,12 @@ void Log::outDetail( const char * str, ... )
|
|||
|
||||
void Log::outDebugInLine( const char * str, ... )
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
if( m_logLevel > 2 )
|
||||
|
||||
if (m_logLevel >= LOG_LVL_DEBUG)
|
||||
{
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDebug]);
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -571,10 +587,11 @@ void Log::outDebugInLine( const char * str, ... )
|
|||
vutf8printf(stdout, str, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(true);
|
||||
}
|
||||
if(logfile && m_logFileLevel > 2)
|
||||
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_DEBUG)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
|
|
@ -585,14 +602,15 @@ void Log::outDebugInLine( const char * str, ... )
|
|||
|
||||
void Log::outDebug( const char * str, ... )
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
if( m_logLevel > 2 )
|
||||
|
||||
if (m_logLevel >= LOG_LVL_DEBUG)
|
||||
{
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDebug]);
|
||||
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -600,12 +618,13 @@ void Log::outDebug( const char * str, ... )
|
|||
vutf8printf(stdout, str, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
if(logfile && m_logFileLevel > 2)
|
||||
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_DEBUG)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
|
||||
|
|
@ -617,20 +636,21 @@ void Log::outDebug( const char * str, ... )
|
|||
fprintf(logfile, "\n" );
|
||||
fflush(logfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::outCommand( uint32 account, const char * str, ... )
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
if( m_logLevel > 1 )
|
||||
if (m_logLevel >= LOG_LVL_DETAIL)
|
||||
{
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
SetColor(true,m_colors[LogDetails]);
|
||||
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -638,12 +658,13 @@ void Log::outCommand( uint32 account, const char * str, ... )
|
|||
vutf8printf(stdout, str, &ap);
|
||||
va_end(ap);
|
||||
|
||||
if(m_colored)
|
||||
if (m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
if(logfile && m_logFileLevel > 1)
|
||||
|
||||
if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
|
||||
{
|
||||
va_list ap;
|
||||
outTimestamp(logfile);
|
||||
|
|
@ -687,7 +708,7 @@ void Log::outChar(const char * str, ... )
|
|||
if (!str)
|
||||
return;
|
||||
|
||||
if(charLogfile)
|
||||
if (charLogfile)
|
||||
{
|
||||
va_list ap;
|
||||
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 )
|
||||
{
|
||||
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 );
|
||||
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, ... )
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
SetColor(true,m_colors[LogNormal]);
|
||||
|
||||
if(m_includeTime)
|
||||
if (m_includeTime)
|
||||
outTime();
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -750,7 +771,7 @@ void Log::outMenu( const char * str, ... )
|
|||
|
||||
ResetColor(true);
|
||||
|
||||
if(logfile)
|
||||
if (logfile)
|
||||
{
|
||||
outTimestamp(logfile);
|
||||
|
||||
|
|
@ -766,11 +787,12 @@ void Log::outMenu( const char * str, ... )
|
|||
|
||||
void Log::outRALog( const char * str, ... )
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
va_list ap;
|
||||
|
||||
if (raLogfile)
|
||||
{
|
||||
va_list ap;
|
||||
outTimestamp(raLogfile);
|
||||
va_start(ap, str);
|
||||
vfprintf(raLogfile, str, ap);
|
||||
|
|
@ -778,12 +800,13 @@ void Log::outRALog( const char * str, ... )
|
|||
va_end(ap);
|
||||
fflush(raLogfile);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void outstring_log(const char * str, ...)
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
char buf[256];
|
||||
|
|
@ -797,7 +820,7 @@ void outstring_log(const char * str, ...)
|
|||
|
||||
void detail_log(const char * str, ...)
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
char buf[256];
|
||||
|
|
@ -811,7 +834,7 @@ void detail_log(const char * str, ...)
|
|||
|
||||
void debug_log(const char * str, ...)
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
char buf[256];
|
||||
|
|
@ -825,7 +848,7 @@ void debug_log(const char * str, ...)
|
|||
|
||||
void error_log(const char * str, ...)
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
char buf[256];
|
||||
|
|
@ -839,7 +862,7 @@ void error_log(const char * str, ...)
|
|||
|
||||
void error_db_log(const char * str, ...)
|
||||
{
|
||||
if( !str )
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
char buf[256];
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9835"
|
||||
#define REVISION_NR "9836"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue