diff options
| author | XTZGZoReX <none@none> | 2009-03-19 21:28:25 +0100 |
|---|---|---|
| committer | XTZGZoReX <none@none> | 2009-03-19 21:28:25 +0100 |
| commit | 3c713189fb6ac6666e6d8e7faa2e1fec6b425725 (patch) | |
| tree | 484e19e955ce3e39c387e868fd89384584b524c7 /src/game/WorldLog.cpp | |
| parent | 9fe43fa9c0bd21f6c203072f19a77a570680ecab (diff) | |
* Correctly implement database logging in WorldLog.
* This fixes LogDB.World config option.
--HG--
branch : trunk
Diffstat (limited to 'src/game/WorldLog.cpp')
| -rw-r--r-- | src/game/WorldLog.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/game/WorldLog.cpp b/src/game/WorldLog.cpp index 7a10986f749..8e870585e9d 100644 --- a/src/game/WorldLog.cpp +++ b/src/game/WorldLog.cpp @@ -25,6 +25,7 @@ #include "WorldLog.h" #include "Policies/SingletonImp.h" #include "Config/ConfigEnv.h" +#include "Log.h" #define CLASS_LOCK Trinity::ClassLevelLockable<WorldLog, ZThread::FastMutex> INSTANTIATE_SINGLETON_2(WorldLog, CLASS_LOCK); @@ -32,6 +33,18 @@ INSTANTIATE_CLASS_MUTEX(WorldLog, ZThread::FastMutex); #define WORLD_LOG_FILE_STRING "world.log" +WorldLog::WorldLog() : i_file(NULL) +{ + Initialize(); +} + +WorldLog::~WorldLog() +{ + if( i_file != NULL ) + fclose(i_file); + i_file = NULL; +} + /// Open the log file (if specified so in the configuration file) void WorldLog::Initialize() { @@ -48,6 +61,35 @@ void WorldLog::Initialize() { i_file = fopen((logsDir+logname).c_str(), "w"); } + + m_dbWorld = sConfig.GetBoolDefault("LogDB.World", false); // can be VERY heavy if enabled +} + +void WorldLog::outLog(char const *fmt, ...) +{ + if( LogWorld() ) + { + Guard guard(*this); + ASSERT(i_file); + + va_list args; + va_start(args, fmt); + vfprintf(i_file, fmt, args); + fprintf(i_file, "\n\n" ); + va_end(args); + + fflush(i_file); + } + + if (sLog.GetLogDB() && m_dbWorld) + { + va_list ap2; + va_start(ap2, fmt); + char nnew_str[MAX_QUERY_LEN]; + vsnprintf(nnew_str, MAX_QUERY_LEN, fmt, ap2); + sLog.outDB(LOG_TYPE_WORLD, nnew_str); + va_end(ap2); + } } #define sWorldLog WorldLog::Instance() |
