Core/Logging: Add config option to enable/disable asyncronous logging (disabled by default)

This commit is contained in:
Spp
2013-01-16 09:52:49 +01:00
parent be3826825e
commit 526bdc0764
2 changed files with 20 additions and 5 deletions

View File

@@ -273,12 +273,16 @@ void Log::vlog(LogFilterType filter, LogLevel level, char const* str, va_list ar
void Log::write(LogMessage* msg)
{
if (loggers.empty())
return;
msg->text.append("\n");
Logger* logger = GetLoggerByType(msg->type);
if (worker)
{
msg->text.append("\n");
Logger* logger = GetLoggerByType(msg->type);
worker->enqueue(new LogOperation(logger, msg));
}
else
logger->write(*msg);
}
std::string Log::GetTimestampStr()
@@ -478,7 +482,10 @@ void Log::Close()
void Log::LoadFromConfig()
{
Close();
worker = new LogWorker();
if (ConfigMgr::GetBoolDefault("Log.Async.Enable", false))
worker = new LogWorker();
AppenderId = 0;
m_logsDir = ConfigMgr::GetStringDefault("LogsDir", "");
if (!m_logsDir.empty())

View File

@@ -2823,5 +2823,13 @@ Logger.Opcodes=41,6,Console Server
Loggers=Root Chat DBErrors GM RA Warden Character Load WorldServer Opcodes
#
# Log.Async.Enable
# Description: Enables asyncronous message logging.
# Default: 0 - (Disabled)
# 1 - (Enabled)
Log.Async.Enable = 0
#
###################################################################################################