te::core::Logger Class Reference

#include <Logger.h>

Public Types

enum  severity_level {
  trace, debug, info, warning,
  error, fatal
}
 

Public Member Functions

void addLogger (const std::string &name, const std::string &filename, std::string format)
 It sets the logger using a default implementation. More...
 
void addLoggerFromFile (const std::string &filename)
 It sets the logger configuration from a given file. More...
 
bool exists (const std::string &name)
 Checks if exists a logger registered with the given name. More...
 
void log (const std::string &message, const std::string &channel, severity_level severity)
 It logs a given string message, channel and severity. More...
 
void removeAllLoggers ()
 It removes all added loggers. More...
 
void setFilter (te::core::Logger::severity_level severity)
 Sets the severity filter for the logger. More...
 

Static Public Member Functions

static Loggerinstance ()
 It returns a reference to the singleton instance. More...
 

Private Member Functions

std::string getLoggingLevelName (te::core::Logger::severity_level severity)
 Convert te::security_level to human readable name. More...
 
 Logger ()
 Singleton constructor must be private or protected. More...
 
 Logger (Logger const &)
 Singleton copy constructor must be private or protected. More...
 
Loggeroperator= (Logger const &)
 Singleton copy assignment operator must be private or protected. More...
 
boost::log::trivial::severity_level toBoostSecurityLevel (te::core::Logger::severity_level severity)
 Convert te::security_level to boost::security_level. More...
 
 ~Logger ()
 Singleton destructor must be private or protected. More...
 

Private Attributes

Impl * m_pimpl
 
std::pair< boost::log::attribute_set::iterator, bool > m_process
 
std::pair< boost::log::attribute_set::iterator, bool > m_processId
 
std::pair< boost::log::attribute_set::iterator, bool > m_threadId
 

Detailed Description

Definition at line 63 of file Logger.h.

Member Enumeration Documentation

◆ severity_level

Enumerator
trace 
debug 
info 
warning 
error 
fatal 

Definition at line 72 of file Logger.h.

Constructor & Destructor Documentation

◆ Logger() [1/2]

te::core::Logger::Logger ( )
private

Singleton constructor must be private or protected.

◆ ~Logger()

te::core::Logger::~Logger ( )
private

Singleton destructor must be private or protected.

◆ Logger() [2/2]

te::core::Logger::Logger ( Logger const &  )
private

Singleton copy constructor must be private or protected.

Member Function Documentation

◆ addLogger()

void te::core::Logger::addLogger ( const std::string &  name,
const std::string &  filename,
std::string  format 
)

It sets the logger using a default implementation.

Parameters
nameThe name of the logger.
filenameThe name of the log file.
formatThe format string of the logger.
Exceptions
te::InvalidArgumentExceptionIf the logger name is empty or already registered
Note
The logs will be stored in the given file name. If the file already exists, the logs will be appended to the end of the file.

◆ addLoggerFromFile()

void te::core::Logger::addLoggerFromFile ( const std::string &  filename)

It sets the logger configuration from a given file.

Parameters
filenameThe name of the configuration file.
Exceptions
std::exceptionIf the configuration file is doesn't load.

◆ exists()

bool te::core::Logger::exists ( const std::string &  name)

Checks if exists a logger registered with the given name.

Parameters
nameThe name to be checked.
Returns
True if a logger with the given name, false if not.

◆ getLoggingLevelName()

std::string te::core::Logger::getLoggingLevelName ( te::core::Logger::severity_level  severity)
private

Convert te::security_level to human readable name.

◆ instance()

static Logger& te::core::Logger::instance ( )
static

It returns a reference to the singleton instance.

Returns
A reference to the singleton instance.

◆ log()

void te::core::Logger::log ( const std::string &  message,
const std::string &  channel,
severity_level  severity 
)

It logs a given string message, channel and severity.

Parameters
messageThe string message to be logged.
channelThe channel name that will receive the message.
severityThe severity of the logged message.

◆ operator=()

Logger& te::core::Logger::operator= ( Logger const &  )
private

Singleton copy assignment operator must be private or protected.

◆ removeAllLoggers()

void te::core::Logger::removeAllLoggers ( )

It removes all added loggers.

◆ setFilter()

void te::core::Logger::setFilter ( te::core::Logger::severity_level  severity)

Sets the severity filter for the logger.

◆ toBoostSecurityLevel()

boost::log::trivial::severity_level te::core::Logger::toBoostSecurityLevel ( te::core::Logger::severity_level  severity)
private

Convert te::security_level to boost::security_level.

Member Data Documentation

◆ m_pimpl

Impl* te::core::Logger::m_pimpl
private

Definition at line 167 of file Logger.h.

◆ m_process

std::pair< boost::log::attribute_set::iterator, bool > te::core::Logger::m_process
private

Definition at line 169 of file Logger.h.

◆ m_processId

std::pair< boost::log::attribute_set::iterator, bool > te::core::Logger::m_processId
private

Definition at line 170 of file Logger.h.

◆ m_threadId

std::pair< boost::log::attribute_set::iterator, bool > te::core::Logger::m_threadId
private

Definition at line 171 of file Logger.h.


The documentation for this class was generated from the following file: