*Add new log level "crash alarm" to record very dangerous errors.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-23 20:09:55 -06:00
parent 84d0aae7fc
commit 04b27302b0
3 changed files with 43 additions and 1 deletions
+40
View File
@@ -402,6 +402,46 @@ void Log::outString( const char * str, ... )
fflush(stdout);
}
void Log::outCrash( const char * err, ... )
{
if( !err )
return;
if (m_enableLogDB)
{
va_list ap2;
va_start(ap2, err);
char nnew_str[MAX_QUERY_LEN];
vsnprintf(nnew_str, MAX_QUERY_LEN, err, ap2);
outDB(LOG_TYPE_CRASH, nnew_str);
va_end(ap2);
}
if(m_colored)
SetColor(false,RED);
UTF8PRINTF(stderr,err,);
if(m_colored)
ResetColor(false);
fprintf( stderr, "\n" );
if(logfile)
{
outTimestamp(logfile);
fprintf(logfile, "CRASH ALARM:" );
va_list ap;
va_start(ap, err);
vfprintf(logfile, err, ap);
va_end(ap);
fprintf(logfile, "\n" );
fflush(logfile);
}
fflush(stderr);
}
void Log::outError( const char * err, ... )
{
if( !err )
+2
View File
@@ -47,6 +47,7 @@ enum LogTypes
LOG_TYPE_RA = 7,
LOG_TYPE_GM = 8,
LOG_TYPE_PACKET = 9,
LOG_TYPE_CRASH = 10,
MAX_LOG_TYPES
};
@@ -97,6 +98,7 @@ class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ZThr
void outDB( uint8 type, const char * str, ... ) ATTR_PRINTF(3,4);
void outString( const char * str, ... ) ATTR_PRINTF(2,3);
void outError( const char * err, ... ) ATTR_PRINTF(2,3);
void outCrash( const char * err, ... ) ATTR_PRINTF(2,3);
void outBasic( const char * str, ... ) ATTR_PRINTF(2,3);
void outDetail( const char * str, ... ) ATTR_PRINTF(2,3);
void outDebug( const char * str, ... ) ATTR_PRINTF(2,3);