mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 13:41:31 +00:00
Add extra checking at the root of Log.Out to check if the category is subscribed to any of the output methods before trying to parse message strings and then pass them to the sub output functions and THEN perform log_setting checks and debug_level checks.
I performed a unit test of 1,000,000 log writes, there is hardly any difference. #::: Before Checks [01-25-2015 :: 03:15:35] [999999] Test #2... Took 17.940001 seconds #::: With Checks [01-25-2015 :: 04:10:55] [999999] Test #2... Took 18.018000 seconds
This commit is contained in:
parent
4f19fe9f91
commit
5266d7b25c
@ -269,6 +269,13 @@ void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category,
|
||||
|
||||
void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...)
|
||||
{
|
||||
const bool log_to_console = log_settings[log_category].log_to_console > 0;
|
||||
const bool log_to_file = log_settings[log_category].log_to_file > 0;
|
||||
const bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0;
|
||||
const bool nothing_to_log = !log_to_console && !log_to_file && !log_to_gmsay;
|
||||
|
||||
if (nothing_to_log) return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
std::string output_message = vStringFormat(message.c_str(), args);
|
||||
@ -276,9 +283,9 @@ void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::st
|
||||
|
||||
std::string output_debug_message = EQEmuLogSys::FormatOutMessageString(log_category, output_message);
|
||||
|
||||
EQEmuLogSys::ProcessConsoleMessage(debug_level, log_category, output_debug_message);
|
||||
EQEmuLogSys::ProcessGMSay(debug_level, log_category, output_debug_message);
|
||||
EQEmuLogSys::ProcessLogWrite(debug_level, log_category, output_message);
|
||||
if (log_to_console) EQEmuLogSys::ProcessConsoleMessage(debug_level, log_category, output_debug_message);
|
||||
if (log_to_gmsay) EQEmuLogSys::ProcessGMSay(debug_level, log_category, output_debug_message);
|
||||
if (log_to_file) EQEmuLogSys::ProcessLogWrite(debug_level, log_category, output_message);
|
||||
}
|
||||
|
||||
void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp)
|
||||
|
||||
@ -10472,19 +10472,10 @@ void command_logtest(Client *c, const Seperator *sep){
|
||||
clock_t t = std::clock(); /* Function timer start */
|
||||
if (sep->IsNumber(1)){
|
||||
uint32 i = 0;
|
||||
std::ofstream log_test;
|
||||
for (i = 0; i < atoi(sep->arg[1]); i++){
|
||||
log_test.open("logs/log_test.txt", std::ios_base::app | std::ios_base::out);
|
||||
log_test << "this is a test\n";
|
||||
log_test.close();
|
||||
}
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "[%u] Test #1... Took %f seconds", i, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
|
||||
t = std::clock();
|
||||
log_test.open("logs/log_test.txt", std::ios_base::app | std::ios_base::out);
|
||||
for (i = 0; i < atoi(sep->arg[1]); i++){
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "[%u] Test #2... Took %f seconds", i, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
|
||||
Log.Out(Logs::General, Logs::Debug, "[%u] Test #2... Took %f seconds", i, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
|
||||
}
|
||||
log_test.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user