Public Types | |
enum | Level { All = 00, Trace = 10, Debug = 20, Info = 30, Warning = 40, Error = 50, Fatal = 60, OFF = 90 } |
Logging threshold. More... | |
Public Member Functions | |
Logger () | |
Construct logger. | |
virtual | ~Logger () |
Provide virtual destructor. | |
void | setPrimaryAppender (Appender *app) |
Sets the primary appender. | |
Appender * | getPrimaryAppender () const |
Gets the primary appender. | |
void | setSecondaryAppender (Appender *app) |
Sets the secondary appender. | |
Appender * | getSecondaryAppender () const |
Gets the secondary appender. | |
void | setLevel (Level level) |
Sets the current log level. | |
Level | getLevel () const |
Gets the current log level. | |
bool | isLogged (Level level) const |
Tests the current log level. | |
bool | isLocationInfoEnabled () const |
Tests if location info should be logged. | |
void | setLocationInfoEnabled (bool enable) |
Enables logging of location information. | |
void | log (Level level, std::string msg, std::string category="", const LocationInformation *info=0) |
Sends a message to the log. | |
void | trace (std::string msg, std::string category="", const LocationInformation *info=0) |
Sends a trace message to the log. | |
void | debug (std::string msg, std::string category="", const LocationInformation *info=0) |
Sends a debug message to the log. | |
void | info (std::string msg, std::string category="", const LocationInformation *info=0) |
Sends an information message to the log. | |
void | warn (std::string msg, std::string category="", const LocationInformation *info=0) |
Sends a warning message to the log. | |
void | error (std::string msg, std::string category="", const LocationInformation *info=0) |
Sends an error message to the log. | |
void | fatal (std::string msg, std::string category="", const LocationInformation *info=0) |
Sends a fatal message to the log. | |
NDC & | ndc () |
Returns the nested diagnostics object. | |
MDC & | mdc () |
Returns the nested diagnostics object. | |
Property & | property () |
Returns the current property set. | |
Static Public Member Functions | |
static Logger & | logger () |
Gets the default logger object. | |
static void | initLogging (const std::string &appname, const std::string &hostname) |
Sets the default logger object. | |
static void | initLogging (Appender *prim_app, Appender *sec_app) |
Sets the default logger object. | |
static LOG4SENDPP_INT64 | currentTimeMillis () |
The number of milliseconds elapsed from 1/1/1970 until logging event was created. | |
Classes | |
struct | DiagnosticInformation |
Keep additional diagnostic info. More... |
Definition at line 49 of file logger.h.
enum l4snd::Logger::Level |
Logger & l4snd::Logger::logger | ( | ) | [static] |
Gets the default logger object.
Definition at line 97 of file logger.cpp.
References initLogging().
void l4snd::Logger::initLogging | ( | const std::string & | appname, | |
const std::string & | hostname | |||
) | [static] |
Sets the default logger object.
Based on the appname a TcpIpAppender
and a FileAppender
are set as appenders. Targets are "localhost" and a file beginning with appname in the current directory.
appname | name of the running application. | |
hostname | name of the logging host (port is 4448) |
Definition at line 80 of file logger.cpp.
Referenced by logger().
Sets the default logger object.
prim_app | pointer to new primary appender | |
sec_app | pointer to new secondary appender |
Definition at line 88 of file logger.cpp.
References setPrimaryAppender(), and setSecondaryAppender().
void l4snd::Logger::setPrimaryAppender | ( | Appender * | app | ) |
Sets the primary appender.
The primary appender is tested first for a working state. Should this fail the second appender is checked. The default logger has TcpIpAppender
as primary and FileAppender
as a fallback.
app | pointer to appender object (takes ownership) |
Definition at line 109 of file logger.cpp.
Referenced by initLogging().
Appender * l4snd::Logger::getPrimaryAppender | ( | ) | const |
Gets the primary appender.
Definition at line 117 of file logger.cpp.
void l4snd::Logger::setSecondaryAppender | ( | Appender * | app | ) |
Sets the secondary appender.
See setPrimaryAppender
.
app | pointer to appender object (takes ownership) |
Definition at line 123 of file logger.cpp.
Referenced by initLogging().
Appender * l4snd::Logger::getSecondaryAppender | ( | ) | const |
Gets the secondary appender.
Definition at line 130 of file logger.cpp.
void l4snd::Logger::setLevel | ( | Level | level | ) |
Sets the current log level.
Messages are only logged if the level of the request if equal to or above this value.
level | new log threshold |
Definition at line 136 of file logger.cpp.
Referenced by Logger().
Logger::Level l4snd::Logger::getLevel | ( | ) | const |
bool l4snd::Logger::isLogged | ( | Level | level | ) | const |
Tests the current log level.
level | log threshold |
Definition at line 148 of file logger.cpp.
bool l4snd::Logger::isLocationInfoEnabled | ( | ) | const |
Tests if location info should be logged.
Diabling this part might increase performance
Definition at line 154 of file logger.cpp.
void l4snd::Logger::setLocationInfoEnabled | ( | bool | enable | ) |
Enables logging of location information.
Diabling this part might increase performance
enable | true: log location info |
Definition at line 160 of file logger.cpp.
Referenced by Logger().
void l4snd::Logger::log | ( | Level | level, | |
std::string | msg, | |||
std::string | category = "" , |
|||
const LocationInformation * | info = 0 | |||
) |
Sends a message to the log.
Messages are only logged if the level of the request if equal to or above this value. To avoid runtime penalties you should check the level in advance with isLogged
.
level | log threshold | |
msg | message to log | |
category | message category | |
info | pointer to information about the caller |
Definition at line 238 of file logger.cpp.
References l4snd::Appender::append(), currentTimeMillis(), l4snd::Appender::isWorking(), and LOG4SENDPP_INT64.
Referenced by debug(), error(), fatal(), info(), trace(), and warn().
void l4snd::Logger::trace | ( | std::string | msg, | |
std::string | category = "" , |
|||
const LocationInformation * | info = 0 | |||
) |
Sends a trace message to the log.
msg | message to log | |
category | message category | |
info | pointer to information about the caller |
Definition at line 167 of file logger.cpp.
void l4snd::Logger::debug | ( | std::string | msg, | |
std::string | category = "" , |
|||
const LocationInformation * | info = 0 | |||
) |
Sends a debug message to the log.
msg | message to log | |
category | message category | |
info | pointer to information about the caller |
Definition at line 176 of file logger.cpp.
void l4snd::Logger::info | ( | std::string | msg, | |
std::string | category = "" , |
|||
const LocationInformation * | info = 0 | |||
) |
Sends an information message to the log.
msg | message to log | |
category | message category | |
info | pointer to information about the caller |
Definition at line 185 of file logger.cpp.
void l4snd::Logger::warn | ( | std::string | msg, | |
std::string | category = "" , |
|||
const LocationInformation * | info = 0 | |||
) |
Sends a warning message to the log.
msg | message to log | |
category | message category | |
info | pointer to information about the caller |
Definition at line 194 of file logger.cpp.
void l4snd::Logger::error | ( | std::string | msg, | |
std::string | category = "" , |
|||
const LocationInformation * | info = 0 | |||
) |
Sends an error message to the log.
msg | message to log | |
category | message category | |
info | pointer to information about the caller |
Definition at line 203 of file logger.cpp.
void l4snd::Logger::fatal | ( | std::string | msg, | |
std::string | category = "" , |
|||
const LocationInformation * | info = 0 | |||
) |
Sends a fatal message to the log.
msg | message to log | |
category | message category | |
info | pointer to information about the caller |
Definition at line 212 of file logger.cpp.
NDC & l4snd::Logger::ndc | ( | ) |
Returns the nested diagnostics object.
Definition at line 220 of file logger.cpp.
MDC & l4snd::Logger::mdc | ( | ) |
Returns the nested diagnostics object.
Definition at line 226 of file logger.cpp.
Property & l4snd::Logger::property | ( | ) |
Returns the current property set.
Definition at line 232 of file logger.cpp.
LOG4SENDPP_INT64 l4snd::Logger::currentTimeMillis | ( | ) | [static] |
The number of milliseconds elapsed from 1/1/1970 until logging event was created.
Definition at line 256 of file logger.cpp.
References LOG4SENDPP_INT64.
Referenced by log().