diff options
author | Spp <spp@jorge.gr> | 2013-11-11 14:34:44 +0100 |
---|---|---|
committer | Spp <spp@jorge.gr> | 2013-11-11 14:35:16 +0100 |
commit | cd486622333c9d0c725e882d149fe8d4ad342e2a (patch) | |
tree | fee3c2d8bba1828c2577fc9feac89c021ee8be74 /src/server/shared/Logging/Log.h | |
parent | 79a2d6b7fc9e516435ff6e035ad869aad1cae876 (diff) |
Core/Logging: Minor changes
- Select stderr when writing ERROR and FATAL messages
- Simplify function defines
- Fix `logs` table structure with latest logging changes
Diffstat (limited to 'src/server/shared/Logging/Log.h')
-rw-r--r-- | src/server/shared/Logging/Log.h | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index e2e942d7e9b..af522a6745f 100644 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -21,8 +21,8 @@ #include "Define.h" #include "Appender.h" -#include "LogWorker.h" #include "Logger.h" +#include "LogWorker.h" #include "Dynamic/UnorderedMap.h" #include <string> @@ -46,20 +46,15 @@ class Log bool ShouldLog(std::string const& type, LogLevel level) const; bool SetLogLevel(std::string const& name, char const* level, bool isLogger = true); - void outTrace(std::string const& f, char const* str, ...) ATTR_PRINTF(3, 4); - void outDebug(std::string const& f, char const* str, ...) ATTR_PRINTF(3, 4); - void outInfo(std::string const& f, char const* str, ...) ATTR_PRINTF(3, 4); - void outWarn(std::string const& f, char const* str, ...) ATTR_PRINTF(3, 4); - void outError(std::string const& f, char const* str, ...) ATTR_PRINTF(3, 4); - void outFatal(std::string const& f, char const* str, ...) ATTR_PRINTF(3, 4); + void outMessage(std::string const& f, LogLevel level, char const* str, ...) ATTR_PRINTF(4, 5); void outCommand(uint32 account, const char * str, ...) ATTR_PRINTF(3, 4); void outCharDump(char const* str, uint32 account_id, uint32 guid, char const* name); - static std::string GetTimestampStr(); void SetRealmId(uint32 id); private: + static std::string GetTimestampStr(); void vlog(std::string const& f, LogLevel level, char const* str, va_list argptr); void write(LogMessage* msg) const; @@ -112,41 +107,51 @@ inline bool Log::ShouldLog(std::string const& type, LogLevel level) const return logLevel != LOG_LEVEL_DISABLED && logLevel <= level; } +inline void Log::outMessage(std::string const& filter, LogLevel level, const char * str, ...) +{ + va_list ap; + va_start(ap, str); + + vlog(filter, level, str, ap); + + va_end(ap); +} + #define sLog ACE_Singleton<Log, ACE_Thread_Mutex>::instance() #if COMPILER != COMPILER_MICROSOFT -#define TC_LOG_MESSAGE_BODY(level__, call__, filterType__, ...) \ - do { \ - if (sLog->ShouldLog(filterType__, level__)) \ - sLog->call__(filterType__, __VA_ARGS__); \ +#define TC_LOG_MESSAGE_BODY(filterType__, level__, ...) \ + do { \ + if (sLog->ShouldLog(filterType__, level__)) \ + sLog->outMessage(filterType__, level__, __VA_ARGS__); \ } while (0) #else -#define TC_LOG_MESSAGE_BODY(level__, call__, filterType__, ...) \ - __pragma(warning(push)) \ - __pragma(warning(disable:4127)) \ - do { \ - if (sLog->ShouldLog(filterType__, level__)) \ - sLog->call__(filterType__, __VA_ARGS__); \ - } while (0) \ +#define TC_LOG_MESSAGE_BODY(filterType__, level__, ...) \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + do { \ + if (sLog->ShouldLog(filterType__, level__)) \ + sLog->outMessage(filterType__, level__, __VA_ARGS__); \ + } while (0) \ __pragma(warning(pop)) #endif #define TC_LOG_TRACE(filterType__, ...) \ - TC_LOG_MESSAGE_BODY(LOG_LEVEL_TRACE, outTrace, filterType__, __VA_ARGS__) + TC_LOG_MESSAGE_BODY(filterType__, LOG_LEVEL_TRACE, __VA_ARGS__) #define TC_LOG_DEBUG(filterType__, ...) \ - TC_LOG_MESSAGE_BODY(LOG_LEVEL_DEBUG, outDebug, filterType__, __VA_ARGS__) + TC_LOG_MESSAGE_BODY(filterType__, LOG_LEVEL_DEBUG, __VA_ARGS__) #define TC_LOG_INFO(filterType__, ...) \ - TC_LOG_MESSAGE_BODY(LOG_LEVEL_INFO, outInfo, filterType__, __VA_ARGS__) + TC_LOG_MESSAGE_BODY(filterType__, LOG_LEVEL_INFO, __VA_ARGS__) #define TC_LOG_WARN(filterType__, ...) \ - TC_LOG_MESSAGE_BODY(LOG_LEVEL_WARN, outWarn, filterType__, __VA_ARGS__) + TC_LOG_MESSAGE_BODY(filterType__, LOG_LEVEL_WARN, __VA_ARGS__) #define TC_LOG_ERROR(filterType__, ...) \ - TC_LOG_MESSAGE_BODY(LOG_LEVEL_ERROR, outError, filterType__, __VA_ARGS__) + TC_LOG_MESSAGE_BODY(filterType__, LOG_LEVEL_ERROR, __VA_ARGS__) #define TC_LOG_FATAL(filterType__, ...) \ - TC_LOG_MESSAGE_BODY(LOG_LEVEL_FATAL, outFatal, filterType__, __VA_ARGS__) + TC_LOG_MESSAGE_BODY(filterType__, LOG_LEVEL_FATAL, __VA_ARGS__) #endif |