HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Types | Public Member Functions
rwsf::Logger Class Reference

Provides an interface for writing log messages to the logging framework. More...

#include <rwsf/core/Logger.h>

Inheritance diagram for rwsf::Logger:
rwsf::HandleBase

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)
 
Loggeroperator= (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
 
HandleBaseoperator= (const HandleBase &second)
 

Detailed Description

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:

logger.error("Subsystem configuration not found.");
logger.log(rwsf::Logger::LOG_FATAL, "Couldn't load subsystem!");

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.

Member Enumeration Documentation

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.

Enumerator
LOG_NONE 

Not for general use, just used as a placeholder for 0 value.

LOG_FATAL 

Fatal errors which cause program termination.

LOG_ERROR 

Errors which can be recovered, but need to be flagged as important.

LOG_WARN 

Warnings which may not indicate an error condition, but a potential problem.

LOG_INFO 

Routine informational messages that should be printed out in normal use.

LOG_VERBOSE 

Verbose informational messages that might help shed light into a problem.

LOG_DEBUG 

Debugging information for debugging a major problem. Very verbose.

LOG_DEV 

Debugging information used during development work. Most verbose level.

Constructor & Destructor Documentation

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.

Member Function Documentation

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.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.