EpcTools
An event based multi-threaded C++ development framework.
Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Friends | List of all members
ELogger Class Reference

Defines a logger. More...

#include <elogger.h>

Public Types

enum  LogLevel {
  eDebug = spdlog::level::trace, eInfo = spdlog::level::debug, eStartup = spdlog::level::info, eMinor = spdlog::level::warn,
  eMajor = spdlog::level::err, eCritical = spdlog::level::critical, eOff = spdlog::level::off
}
 Defines the various log levels. More...
 

Public Member Functions

 ELogger (Int logid, cpStr category, Int sinkid)
 Class constructor. More...
 
 ~ELogger ()
 Class destructor. More...
 
template<typename... Args>
Void debug (cpStr format, const Args &... args)
 Writes a debug message to this logger. More...
 
template<typename... Args>
Void info (cpStr format, const Args &... args)
 Writes a info message to this logger. More...
 
template<typename... Args>
Void startup (cpStr format, const Args &... args)
 Writes a startup message to this logger. More...
 
template<typename... Args>
Void minor (cpStr format, const Args &... args)
 Writes a minor message to this logger. More...
 
template<typename... Args>
Void major (cpStr format, const Args &... args)
 Writes a major message to this logger. More...
 
template<typename... Args>
Void critical (cpStr format, const Args &... args)
 Writes a critical message to this logger. More...
 
Void flush ()
 Flushes any unwritten log messages to the underlying sinks. More...
 
Void setLogLevel (LogLevel lvl)
 Assign a log level for this logger. Any log messages lower than the specified log level will not be written. More...
 
LogLevel getLogLevel ()
 Retrieve the currently assigned log level. More...
 
const std::string & get_name ()
 Retrieve the name (category) of the logger. More...
 
spdlog::level::level_enum get_level ()
 Retrieve the current log level from the underlying spdlog object. More...
 
Void set_level (spdlog::level::level_enum lvl)
 Sets the current log level of the underlying spdlog object. More...
 
const std::map< std::string, std::shared_ptr< ELogger > > get_loggers ()
 Retrieve the defined loggers. More...
 

Static Public Member Functions

static EStringapplicationName ()
 Retrieves the application name. More...
 
static EStringapplicationName (cpStr app)
 Assigns the application name. More...
 
static ELoggercreateLog (Int logid, cpStr category, Int sinkid)
 Manually creates a logger. More...
 
static ELoggerSinkSetcreateSinkSet (Int sinkid)
 Manually creates a sink set. More...
 
static ELoggerlog (Int logid)
 Retrieves the requested ELogger object. More...
 
static ELoggerSinkSetsinkSet (Int sinkid)
 Retrieves the requested sink set object. More...
 

Static Protected Member Functions

static Void init (EGetOpt &opt)
 Initilizes the logs from the configuration file. More...
 
static Void uninit ()
 Shuts down the logging system. More...
 

Friends

class ELoggerInit
 

Detailed Description

Defines a logger.

Member Enumeration Documentation

◆ LogLevel

Defines the various log levels.

Enumerator
eDebug 

Debug.

eInfo 

Informational.

eStartup 

Startup.

eMinor 

Minor.

eMajor 

Major.

eCritical 

Critical.

eOff 

Disables logging.

Constructor & Destructor Documentation

◆ ELogger()

ELogger::ELogger ( Int  logid,
cpStr  category,
Int  sinkid 
)

Class constructor.

Parameters
logidthe log ID for this logger.
categorythe category description for this log.
sinkididentifies the set of output sinks for this logger.

◆ ~ELogger()

ELogger::~ELogger ( )
inline

Class destructor.

Member Function Documentation

◆ applicationName() [1/2]

static EString& ELogger::applicationName ( )
inlinestatic

Retrieves the application name.

Returns
the application name.

◆ applicationName() [2/2]

static EString& ELogger::applicationName ( cpStr  app)
inlinestatic

Assigns the application name.

Returns
the application name.

◆ createLog()

ELogger & ELogger::createLog ( Int  logid,
cpStr  category,
Int  sinkid 
)
static

Manually creates a logger.

Parameters
logidthe log ID for this logger.
categorythe category description for this log.
sinkididentifies the set of output sinks for this logger.
Returns
the newly created logger.
Exceptions
ELoggerError_LogExists
ELoggerError_SinkSetNotFound

◆ createSinkSet()

ELoggerSinkSet & ELogger::createSinkSet ( Int  sinkid)
static

Manually creates a sink set.

Parameters
sinkidthe sink ID to assign to this sink set.
Returns
the newly created sink set object.
Exceptions
ELoggerError_SinkSetExists

◆ critical()

template<typename... Args>
Void ELogger::critical ( cpStr  format,
const Args &...  args 
)
inline

Writes a critical message to this logger.

Parameters
formatthe format of the log message.
argsany arguments that will be substituted into the log format.

◆ debug()

template<typename... Args>
Void ELogger::debug ( cpStr  format,
const Args &...  args 
)
inline

Writes a debug message to this logger.

Parameters
formatthe format of the log message.
argsany arguments that will be substituted into the log format.

◆ flush()

Void ELogger::flush ( )
inline

Flushes any unwritten log messages to the underlying sinks.

◆ get_level()

spdlog::level::level_enum ELogger::get_level ( )
inline

Retrieve the current log level from the underlying spdlog object.

Returns
the spdlog log level.

◆ get_loggers()

const std::map<std::string,std::shared_ptr<ELogger> > ELogger::get_loggers ( )
inline

Retrieve the defined loggers.

Returns
the logger collection.

◆ get_name()

const std::string& ELogger::get_name ( )
inline

Retrieve the name (category) of the logger.

Returns
the logger name.

◆ getLogLevel()

LogLevel ELogger::getLogLevel ( )
inline

Retrieve the currently assigned log level.

Returns
the current log level.

◆ info()

template<typename... Args>
Void ELogger::info ( cpStr  format,
const Args &...  args 
)
inline

Writes a info message to this logger.

Parameters
formatthe format of the log message.
argsany arguments that will be substituted into the log format.

◆ init()

Void ELogger::init ( EGetOpt opt)
staticprotected

Initilizes the logs from the configuration file.

Parameters
optthe options that contain the settings loaded from the configuration file.
Exceptions
ELoggerError_SinkSetLogIdNotSpecified
ELoggerError_SinkSetSinkIdNotSpecified
ELoggerError_SinkSetCategoryNotSpecified

◆ log()

static ELogger& ELogger::log ( Int  logid)
inlinestatic

Retrieves the requested ELogger object.

Parameters
logidthe log ID for the logger.
Returns
the logger.
Exceptions
ELoggerError_LogNotFound

◆ major()

template<typename... Args>
Void ELogger::major ( cpStr  format,
const Args &...  args 
)
inline

Writes a major message to this logger.

Parameters
formatthe format of the log message.
argsany arguments that will be substituted into the log format.

◆ minor()

template<typename... Args>
Void ELogger::minor ( cpStr  format,
const Args &...  args 
)
inline

Writes a minor message to this logger.

Parameters
formatthe format of the log message.
argsany arguments that will be substituted into the log format.

◆ set_level()

Void ELogger::set_level ( spdlog::level::level_enum  lvl)
inline

Sets the current log level of the underlying spdlog object.

Parameters
lvlthe spdlog log level.

◆ setLogLevel()

Void ELogger::setLogLevel ( LogLevel  lvl)
inline

Assign a log level for this logger. Any log messages lower than the specified log level will not be written.

Parameters
lvlthe log level to assign.

◆ sinkSet()

static ELoggerSinkSet& ELogger::sinkSet ( Int  sinkid)
inlinestatic

Retrieves the requested sink set object.

Parameters
sinkidthe sink set ID.
Returns
the sink set object.
Exceptions
ELoggerError_SinkSetNotFound

◆ startup()

template<typename... Args>
Void ELogger::startup ( cpStr  format,
const Args &...  args 
)
inline

Writes a startup message to this logger.

Parameters
formatthe format of the log message.
argsany arguments that will be substituted into the log format.

◆ uninit()

Void ELogger::uninit ( )
staticprotected

Shuts down the logging system.

Friends And Related Function Documentation

◆ ELoggerInit

friend class ELoggerInit
friend

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