HydraExpress™ C++ 2020 |
HydraExpress™ C++ API Reference Guide |
Product Documentation: HydraExpress C++ Documentation Home |
Provides an interface for writing log messages to the logging framework. More...
#include <rwsf/core/Logger.h>
Public Types | |
enum | LogLevel { LOG_NONE, LOG_FATAL, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_VERBOSE, LOG_DEBUG, LOG_DEV } |
Public Member Functions | |
Logger () | |
void | debug (const std::string &message) |
void | debug (const rwsf::LogMessage &message) |
void | dev (const std::string &message) |
void | dev (const rwsf::LogMessage &message) |
void | error (const std::string &message) |
void | error (const rwsf::LogMessage &message) |
void | fatal (const std::string &message) |
void | fatal (const rwsf::LogMessage &message) |
std::string | getName () const |
void | info (const std::string &message) |
void | info (const rwsf::LogMessage &message) |
void | init (const rwsf::Config &config) |
void | log (Logger::LogLevel level, const std::string &message) |
void | log (Logger::LogLevel level, const rwsf::LogMessage &message) |
Logger & | operator= (const rwsf::Logger &logger) |
void | verbose (const std::string &message) |
void | verbose (const rwsf::LogMessage &message) |
void | warn (const std::string &message) |
void | warn (const rwsf::LogMessage &message) |
bool | wouldLog (Logger::LogLevel level) |
Public Member Functions inherited from rwsf::HandleBase | |
bool | isValid (void) const |
bool | operator!= (const HandleBase &second) const |
bool | operator== (const HandleBase &second) const |
Additional Inherited Members | |
Protected Member Functions inherited from rwsf::HandleBase | |
HandleBase (void) | |
HandleBase (StaticCtor) | |
HandleBase (BodyBase *body) | |
HandleBase (const HandleBase &second) | |
virtual | ~HandleBase (void) |
BodyBase & | body (void) const |
HandleBase & | operator= (const HandleBase &second) |
Logger provides an interface for writing log messages to the logging framework. Log messages are classified by log level. The lowest level is the least verbose (although the most catastrophic), while the highest level is the most verbose. See the LogLevel enumeration.
Loggers should only be retrieved from the rwsf::LogManager singleton. On startup, the LogManager loads the logger definitions specified in the logging configuration file (typically loggers.xml) and makes those available via the getLogger() function.
Example of usage:
The first usage of the logger shows how to use the fatal(), error(), warn(), info(), verbose(), debug(), and dev() functions to log at the respective levels. The second usage shows the general log() function that takes a logging level as its first parameter.
The destination of the log message depends entirely on how the logger is defined in the configuration file, whether it uses the LogLevelFilter with a LogFileWriter, or whether it goes directly to stdout, or something else.
Log level enumeration. These go from the most catastrophic (fatal errors) to the most verbose (developmental debugging). Note that the "high" levels are the most verbose ones, not the most serious ones.
rwsf::Logger::Logger | ( | ) |
Constructs an invalid logger. It must be assigned to a valid Logger instance for it to become functional. Any usage of an invalid logger throws rwsf::NullPointerException.
void rwsf::Logger::debug | ( | const std::string & | message | ) |
Logs the specified message at the debug level.
void rwsf::Logger::debug | ( | const rwsf::LogMessage & | message | ) |
Logs the specified message at the debug level.
void rwsf::Logger::dev | ( | const std::string & | message | ) |
Logs the specified message at the development debug level.
void rwsf::Logger::dev | ( | const rwsf::LogMessage & | message | ) |
Logs the specified message at the development debug level.
void rwsf::Logger::error | ( | const std::string & | message | ) |
Logs the specified message at the non-fatal error level.
void rwsf::Logger::error | ( | const rwsf::LogMessage & | message | ) |
Logs the specified message at the non-fatal error level.
void rwsf::Logger::fatal | ( | const std::string & | message | ) |
Logs the specified message at the fatal level.
void rwsf::Logger::fatal | ( | const rwsf::LogMessage & | message | ) |
Logs the specified message at the fatal level.
std::string rwsf::Logger::getName | ( | ) | const |
Returns the name of this logger.
void rwsf::Logger::info | ( | const std::string & | message | ) |
Logs the specified message at the basic info level.
void rwsf::Logger::info | ( | const rwsf::LogMessage & | message | ) |
Logs the specified message at the basic info level.
void rwsf::Logger::init | ( | const rwsf::Config & | config | ) |
Initializes a new logger based on the configuration information provided. The Config object passed to this method holds the logger configuration specified in the logger configuration file, typically loggers.xml.
void rwsf::Logger::log | ( | Logger::LogLevel | level, |
const std::string & | message | ||
) |
Logs the specified message at the given level.
void rwsf::Logger::log | ( | Logger::LogLevel | level, |
const rwsf::LogMessage & | message | ||
) |
Logs the specified message at the given level.
Logger& rwsf::Logger::operator= | ( | const rwsf::Logger & | logger | ) |
Assigns this Logger to be a handle to the logger implementation used by logger. This does not copy the underlying logger implementation.
void rwsf::Logger::verbose | ( | const std::string & | message | ) |
Logs the specified message at the verbose level.
void rwsf::Logger::verbose | ( | const rwsf::LogMessage & | message | ) |
Logs the specified message at the verbose level.
void rwsf::Logger::warn | ( | const std::string & | message | ) |
Logs the specified message at the important warning level.
void rwsf::Logger::warn | ( | const rwsf::LogMessage & | message | ) |
Logs the specified message at the important warning level.
bool rwsf::Logger::wouldLog | ( | Logger::LogLevel | level | ) |
Returns true
if the logger would log the given level. This is useful to check the behavior of a logger in its current configuration.
Copyright © 2020 Rogue Wave Software, Inc. All Rights Reserved. |