ddt 1.1.0
Loading...
Searching...
No Matches
Static Public Attributes | List of all members
ddt::DdtLogger Class Reference

#include <ddtLogger.hpp>

Static Public Attributes

static const int DDT_OFF = 6
 
static const int DDT_FATAL = 5
 
static const int DDT_ERROR = 4
 
static const int DDT_WARN = 3
 
static const int DDT_INFO = 2
 
static const int DDT_DEBUG = 1
 
static const int DDT_TRACE = 0
 
static const int DDT_ALL = 0
 
 DdtLogger (const std::string &logger_name)
 
 DdtLogger (const std::string &logger_name, const char *const application_path)
 
 DdtLogger (const log4cplus::Logger &log4cplus_logger)
 
virtual ~DdtLogger ()
 
void LogTrace (const std::string &log_msg)
 
void LogDebug (const std::string &log_msg)
 
void LogInfo (const std::string &log_msg)
 
void LogWarn (const std::string &log_msg)
 
void LogError (const std::string &log_msg)
 
void LogFatal (const std::string &log_msg)
 
void Configure (const std::string &mod_name)
 
void SetLogLevel (const int level)
 
void SetLogLevelFromLog4CPlus (const log4cplus::LogLevel level)
 
void Write (const int severity, const std::string &message)
 
static void WriteToLogger (DdtLogger *const logger, const int severity, const std::string &message)
 

Detailed Description

Class to wrap the usage of log4cplus as logging utility. The constructor is called with the logger name as argument. In this simple form, a basic logger is created that just provides a console appender.

In case that the application name is provided as second argument to the constructor, a logging properties file is searched. The file specification is built as follows: 'environment variable DDT_LOGCONFIG_PATH'/log4cplus_'lower case version of the application name'.properties If the environment variable is not defined, or the properties file is not existing, a basic logger will be created that just provides a console appender.

With help of the configure method a module can be specified which is prepended to each log message.

Constructor & Destructor Documentation

◆ DdtLogger() [1/3]

DdtLogger::DdtLogger ( const std::string &  logger_name)
explicit

Constructor

In this form, it will only create a basic logger that provides a console appender.

Set up basic logger with a console appender.

Set default module

◆ DdtLogger() [2/3]

DdtLogger::DdtLogger ( const std::string &  logger_name,
const char *const  application_path 
)

Constructor

In this form, it will look for a configuration file.

The file name will be constructed as follows: 'environment variable DDT_LOGCONFIG_PATH'/log4cplus_'lower case version of the application name'.properties

If the environment variable is not defined, or the properties file is not existing, a basic logger will be created that just provides a console appender.

Get application name from path.

Initialize logging.

Check existence of logging properties.

Configure logging. If properties file is not existing or not found, only a console appender will be available.

Set default module and log level.

◆ DdtLogger() [3/3]

DdtLogger::DdtLogger ( const log4cplus::Logger &  log4cplus_logger)
explicit

Constructor

In this form, it takes a log4cplus logger as input that was created outside. This is for the case that an application creates the log4cplus logger on its own.

◆ ~DdtLogger()

DdtLogger::~DdtLogger ( )
virtual

Destructor

Member Function Documentation

◆ Configure()

void DdtLogger::Configure ( const std::string &  mod_name)

Set the module name that is prepended to the log message when using the write() method.

◆ LogDebug()

void DdtLogger::LogDebug ( const std::string &  log_msg)

Log message with DEBUG log level.

◆ LogError()

void DdtLogger::LogError ( const std::string &  log_msg)

Log message with ERROR log level.

◆ LogFatal()

void DdtLogger::LogFatal ( const std::string &  log_msg)

Log message with FATAL log level.

◆ LogInfo()

void DdtLogger::LogInfo ( const std::string &  log_msg)

Log message with INFO log level.

◆ LogTrace()

void DdtLogger::LogTrace ( const std::string &  log_msg)

Log message with TRACE log level.

◆ LogWarn()

void DdtLogger::LogWarn ( const std::string &  log_msg)

Log message with WARN log level.

◆ SetLogLevel()

void DdtLogger::SetLogLevel ( const int  level)

Set the log level. Afterwards only log messages with a log level equal to or higher than the provided one will be logged. The log level DDT_OFF will switch off the logging completely.

◆ SetLogLevelFromLog4CPlus()

void DdtLogger::SetLogLevelFromLog4CPlus ( const log4cplus::LogLevel  level)

Set the log level, taking a log4cplus log level as argument. Afterwards only log messages with a log level equal to or higher than the provided one will be logged. The log level log4cplus::OFF_LOG_LEVEL will switch off the logging completely.

◆ Write()

void DdtLogger::Write ( const int  severity,
const std::string &  message 
)

Write log messages with the provided severity / log level. The module name that is set with help of the configure() method will be prepended to the message string.

◆ WriteToLogger()

void DdtLogger::WriteToLogger ( DdtLogger *const  logger,
const int  severity,
const std::string &  message 
)
static

Static version of the logging functions for the various log levels. Allows to insert a logger as first parameter.

Member Data Documentation

◆ DDT_ALL

const int ddt::DdtLogger::DDT_ALL = 0
static

Log level DDT_ALL. This is equivalent to the DDT_TRACE log level.

◆ DDT_DEBUG

const int ddt::DdtLogger::DDT_DEBUG = 1
static

Log level DDT_DEBUG.

◆ DDT_ERROR

const int ddt::DdtLogger::DDT_ERROR = 4
static

Log level DDT_ERROR.

◆ DDT_FATAL

const int ddt::DdtLogger::DDT_FATAL = 5
static

Log level DDT_FATAL.

◆ DDT_INFO

const int ddt::DdtLogger::DDT_INFO = 2
static

Log level DDT_INFO.

◆ DDT_OFF

const int ddt::DdtLogger::DDT_OFF = 6
static

Log levels defined as integer constants. Log level DDT_OFF. This can be used to switch off logging completely.

◆ DDT_TRACE

const int ddt::DdtLogger::DDT_TRACE = 0
static

Log level DDT_TRACE.

◆ DDT_WARN

const int ddt::DdtLogger::DDT_WARN = 3
static

Log level DDT_WARN.


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