* Optimized Log::outDB by removing unneeded variadic argument parsing. Also use enum instead of explicit uint32.
--HG-- branch : trunk
This commit is contained in:
+3
-15
@@ -344,28 +344,16 @@ std::string Log::GetTimestampStr()
|
|||||||
return std::string(buf);
|
return std::string(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outDB( uint32 type, const char * str, ... )
|
void Log::outDB( LogTypes type, const char * str )
|
||||||
{
|
{
|
||||||
if(type >= MAX_LOG_TYPES)
|
if(!str || std::string(str).empty() || type >= MAX_LOG_TYPES)
|
||||||
return;
|
|
||||||
|
|
||||||
if(!str)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string new_str(str);
|
std::string new_str(str);
|
||||||
LoginDatabase.escape_string(new_str);
|
LoginDatabase.escape_string(new_str);
|
||||||
char nnew_str[MAX_QUERY_LEN];
|
|
||||||
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, str);
|
|
||||||
int res = vsnprintf(nnew_str, MAX_QUERY_LEN, new_str.c_str(), ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
if ( (res < 0) || (!nnew_str) || (std::string(nnew_str).empty()) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
LoginDatabase.PExecute("INSERT INTO logs (time, realm, type, string) "
|
LoginDatabase.PExecute("INSERT INTO logs (time, realm, type, string) "
|
||||||
"VALUES ("I64FMTD", %u, %u, '%s');", uint64(time(0)), realm, type, nnew_str);
|
"VALUES ("I64FMTD", %u, %u, '%s');", uint64(time(0)), realm, (uint32)type, new_str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outString( const char * str, ... )
|
void Log::outString( const char * str, ... )
|
||||||
|
|||||||
+5
-5
@@ -29,10 +29,10 @@ class Config;
|
|||||||
|
|
||||||
enum LogFilters
|
enum LogFilters
|
||||||
{
|
{
|
||||||
LOG_FILTER_TRANSPORT_MOVES = 0x1,
|
LOG_FILTER_TRANSPORT_MOVES = 1,
|
||||||
LOG_FILTER_CREATURE_MOVES = 0x2,
|
LOG_FILTER_CREATURE_MOVES = 2,
|
||||||
LOG_FILTER_VISIBILITY_CHANGES = 0x4,
|
LOG_FILTER_VISIBILITY_CHANGES = 4,
|
||||||
LOG_FILTER_ACHIEVEMENT_UPDATES = 0x8
|
LOG_FILTER_ACHIEVEMENT_UPDATES = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LogTypes
|
enum LogTypes
|
||||||
@@ -95,7 +95,7 @@ class Log : public Trinity::Singleton<Log, Trinity::ClassLevelLockable<Log, ZThr
|
|||||||
void SetColor(bool stdout_stream, ColorTypes color);
|
void SetColor(bool stdout_stream, ColorTypes color);
|
||||||
void ResetColor(bool stdout_stream);
|
void ResetColor(bool stdout_stream);
|
||||||
|
|
||||||
void outDB( uint32 type, const char * str, ... ) ATTR_PRINTF(3,4);
|
void outDB( LogTypes type, const char * str );
|
||||||
void outString( const char * str, ... ) ATTR_PRINTF(2,3);
|
void outString( const char * str, ... ) ATTR_PRINTF(2,3);
|
||||||
void outString( );
|
void outString( );
|
||||||
void outError( const char * err, ... ) ATTR_PRINTF(2,3);
|
void outError( const char * err, ... ) ATTR_PRINTF(2,3);
|
||||||
|
|||||||
Reference in New Issue
Block a user