ddt 1.1.0
|
#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) |
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.
|
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::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.
|
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.
|
virtual |
Destructor
void DdtLogger::Configure | ( | const std::string & | mod_name | ) |
Set the module name that is prepended to the log message when using the write() method.
void DdtLogger::LogDebug | ( | const std::string & | log_msg | ) |
Log message with DEBUG log level.
void DdtLogger::LogError | ( | const std::string & | log_msg | ) |
Log message with ERROR log level.
void DdtLogger::LogFatal | ( | const std::string & | log_msg | ) |
Log message with FATAL log level.
void DdtLogger::LogInfo | ( | const std::string & | log_msg | ) |
Log message with INFO log level.
void DdtLogger::LogTrace | ( | const std::string & | log_msg | ) |
Log message with TRACE log level.
void DdtLogger::LogWarn | ( | const std::string & | log_msg | ) |
Log message with WARN log level.
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.
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.
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.
|
static |
Static version of the logging functions for the various log levels. Allows to insert a logger as first parameter.
|
static |
Log level DDT_ALL. This is equivalent to the DDT_TRACE log level.
|
static |
Log level DDT_DEBUG.
|
static |
Log level DDT_ERROR.
|
static |
Log level DDT_FATAL.
|
static |
Log level DDT_INFO.
|
static |
Log levels defined as integer constants. Log level DDT_OFF. This can be used to switch off logging completely.
|
static |
Log level DDT_TRACE.
|
static |
Log level DDT_WARN.