AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Appender Class Referenceabstract

#include "Appender.h"

Inheritance diagram for Appender:
AppenderConsole AppenderDB AppenderFile

Public Member Functions

 Appender (uint8 _id, std::string const &name, LogLevel level=LOG_LEVEL_DISABLED, AppenderFlags flags=APPENDER_FLAGS_NONE)
 
virtual ~Appender ()
 
uint8 getId () const
 
std::string const & getName () const
 
virtual AppenderType getType () const =0
 
LogLevel getLogLevel () const
 
AppenderFlags getFlags () const
 
void setLogLevel (LogLevel)
 
void write (LogMessage *message)
 
virtual void setRealmId (uint32)
 

Static Public Member Functions

static char const * getLogLevelString (LogLevel level)
 

Private Member Functions

virtual void _write (LogMessage const *)=0
 

Private Attributes

uint8 id
 
std::string name
 
LogLevel level
 
AppenderFlags flags
 

Detailed Description

Constructor & Destructor Documentation

◆ Appender()

Appender::Appender ( uint8  _id,
std::string const &  name,
LogLevel  level = LOG_LEVEL_DISABLED,
AppenderFlags  flags = APPENDER_FLAGS_NONE 
)
23 :
24 id(_id), name(_name), level(_level), flags(_flags) { }
std::string name
Definition: Appender.h:49
uint8 id
Definition: Appender.h:48
LogLevel level
Definition: Appender.h:50
AppenderFlags flags
Definition: Appender.h:51

◆ ~Appender()

Appender::~Appender ( )
virtual
26{ }

Member Function Documentation

◆ _write()

virtual void Appender::_write ( LogMessage const *  )
privatepure virtual

Implemented in AppenderConsole, AppenderFile, and AppenderDB.

Referenced by write().

◆ getFlags()

AppenderFlags Appender::getFlags ( ) const
44{
45 return flags;
46}

References flags.

◆ getId()

uint8 Appender::getId ( ) const
29{
30 return id;
31}

References id.

Referenced by Log::CreateAppenderFromConfig(), and Log::ReadLoggersFromConfig().

◆ getLogLevel()

LogLevel Appender::getLogLevel ( ) const
39{
40 return level;
41}

References level.

◆ getLogLevelString()

char const * Appender::getLogLevelString ( LogLevel  level)
static
82{
83 switch (level)
84 {
85 case LOG_LEVEL_FATAL:
86 return "FATAL";
87 case LOG_LEVEL_ERROR:
88 return "ERROR";
89 case LOG_LEVEL_WARN:
90 return "WARN";
91 case LOG_LEVEL_INFO:
92 return "INFO";
93 case LOG_LEVEL_DEBUG:
94 return "DEBUG";
95 case LOG_LEVEL_TRACE:
96 return "TRACE";
97 default:
98 return "DISABLED";
99 }
100}
@ LOG_LEVEL_DEBUG
Definition: LogCommon.h:31
@ LOG_LEVEL_ERROR
Definition: LogCommon.h:28
@ LOG_LEVEL_FATAL
Definition: LogCommon.h:27
@ LOG_LEVEL_TRACE
Definition: LogCommon.h:32
@ LOG_LEVEL_WARN
Definition: LogCommon.h:29
@ LOG_LEVEL_INFO
Definition: LogCommon.h:30

References level, LOG_LEVEL_DEBUG, LOG_LEVEL_ERROR, LOG_LEVEL_FATAL, LOG_LEVEL_INFO, LOG_LEVEL_TRACE, and LOG_LEVEL_WARN.

Referenced by write().

◆ getName()

std::string const & Appender::getName ( ) const
34{
35 return name;
36}

References name.

◆ getType()

virtual AppenderType Appender::getType ( ) const
pure virtual

Implemented in AppenderConsole, AppenderFile, and AppenderDB.

◆ setLogLevel()

void Appender::setLogLevel ( LogLevel  _level)
49{
50 level = _level;
51}

References level.

Referenced by Log::SetLogLevel().

◆ setRealmId()

virtual void Appender::setRealmId ( uint32  )
inlinevirtual

Reimplemented in AppenderDB.

43{ }

◆ write()

void Appender::write ( LogMessage message)
54{
55 if (!level || level < message->level)
56 {
57 return;
58 }
59
60 std::ostringstream ss;
61
63 {
64 ss << message->getTimeStr() << ' ';
65 }
66
68 {
70 }
71
73 {
74 ss << '[' << message->type << "] ";
75 }
76
77 message->prefix = ss.str();
78 _write(message);
79}
@ APPENDER_FLAGS_PREFIX_TIMESTAMP
Definition: LogCommon.h:53
@ APPENDER_FLAGS_PREFIX_LOGFILTERTYPE
Definition: LogCommon.h:55
@ APPENDER_FLAGS_PREFIX_LOGLEVEL
Definition: LogCommon.h:54
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
virtual void _write(LogMessage const *)=0
static char const * getLogLevelString(LogLevel level)
Definition: Appender.cpp:81
LogLevel const level
Definition: LogMessage.h:37
std::string const type
Definition: LogMessage.h:38
static std::string getTimeStr(Seconds time)
Definition: LogMessage.cpp:27
std::string prefix
Definition: LogMessage.h:40

References _write(), APPENDER_FLAGS_PREFIX_LOGFILTERTYPE, APPENDER_FLAGS_PREFIX_LOGLEVEL, APPENDER_FLAGS_PREFIX_TIMESTAMP, flags, getLogLevelString(), LogMessage::getTimeStr(), level, LogMessage::level, LogMessage::prefix, Acore::StringFormat(), and LogMessage::type.

Member Data Documentation

◆ flags

AppenderFlags Appender::flags
private

◆ id

uint8 Appender::id
private

Referenced by getId().

◆ level

LogLevel Appender::level
private

◆ name