AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Logger Class Reference

#include "Logger.h"

Public Member Functions

 Logger (std::string const &name, LogLevel level)
 
void addAppender (uint8 type, Appender *appender)
 
void delAppender (uint8 type)
 
std::string const & getName () const
 
LogLevel getLogLevel () const
 
void setLogLevel (LogLevel level)
 
void write (LogMessage *message) const
 

Private Attributes

std::string name
 
LogLevel level
 
std::unordered_map< uint8, Appender * > appenders
 

Detailed Description

Constructor & Destructor Documentation

◆ Logger()

Logger::Logger ( std::string const &  name,
LogLevel  level 
)
22: name(_name), level(_level) { }
LogLevel level
Definition: Logger.h:44
std::string name
Definition: Logger.h:43

Member Function Documentation

◆ addAppender()

void Logger::addAppender ( uint8  type,
Appender appender 
)
35{
36 appenders[id] = appender;
37}
std::unordered_map< uint8, Appender * > appenders
Definition: Logger.h:45

References appenders.

Referenced by Log::ReadLoggersFromConfig().

◆ delAppender()

void Logger::delAppender ( uint8  type)
40{
41 appenders.erase(id);
42}

References appenders.

◆ getLogLevel()

LogLevel Logger::getLogLevel ( ) const
30{
31 return level;
32}

References level.

Referenced by Log::ShouldLog().

◆ getName()

std::string const & Logger::getName ( ) const
25{
26 return name;
27}

References name.

◆ setLogLevel()

void Logger::setLogLevel ( LogLevel  level)
45{
46 level = _level;
47}

References level.

◆ write()

void Logger::write ( LogMessage message) const
50{
51 if (!level || level < message->level || message->text.empty())
52 {
53 //fprintf(stderr, "Logger::write: Logger %s, Level %u. Msg %s Level %u WRONG LEVEL MASK OR EMPTY MSG\n", getName().c_str(), getLogLevel(), message.text.c_str(), message.level);
54 return;
55 }
56
57 for (std::pair<uint8 const, Appender*> const& appender : appenders)
58 if (appender.second)
59 {
60 appender.second->write(message);
61 }
62}
std::string const text
Definition: LogMessage.h:39

References appenders, level, and LogMessage::text.

Referenced by LogOperation::call(), and Log::write().

Member Data Documentation

◆ appenders

std::unordered_map<uint8, Appender*> Logger::appenders
private

Referenced by addAppender(), delAppender(), and write().

◆ level

LogLevel Logger::level
private

Referenced by getLogLevel(), setLogLevel(), and write().

◆ name

std::string Logger::name
private

Referenced by getName().