rwlogo
HydraExpress 4.6

HydraExpress C++ API Reference Guide


   


Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::Logger Class Reference
[Core Logging]

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

#include <rwsf/core/Logger.h>

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

List of all members.

Public Types

enum  LogLevel {
  LOG_NONE, LOG_FATAL, LOG_ERROR, LOG_WARN,
  LOG_INFO, LOG_VERBOSE, LOG_DEBUG, LOG_DEV
}

Public Member Functions

 Logger ()
Loggeroperator= (const rwsf::Logger &logger)
void log (Logger::LogLevel level, const std::string &message)
void log (Logger::LogLevel level, const rwsf::LogMessage &message)
void fatal (const std::string &message)
void fatal (const rwsf::LogMessage &message)
void error (const std::string &message)
void error (const rwsf::LogMessage &message)
void warn (const std::string &message)
void warn (const rwsf::LogMessage &message)
void info (const std::string &message)
void info (const rwsf::LogMessage &message)
void verbose (const std::string &message)
void verbose (const rwsf::LogMessage &message)
void debug (const std::string &message)
void debug (const rwsf::LogMessage &message)
void dev (const std::string &message)
void dev (const rwsf::LogMessage &message)
std::string getName () const
void init (const rwsf::Config &config)
bool wouldLog (Logger::LogLevel level)

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:

   rwsf::Logger logger = rwsf::LogManager::getLogger();
   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 rwsf::LogMessage message  ) 

Logs the specified message at the debug level.

void rwsf::Logger::debug ( const std::string &  message  ) 

Logs the specified message at the debug level.

void rwsf::Logger::dev ( const rwsf::LogMessage message  ) 

Logs the specified message at the development debug level.

void rwsf::Logger::dev ( const std::string &  message  ) 

Logs the specified message at the development debug level.

void rwsf::Logger::error ( const rwsf::LogMessage message  ) 

Logs the specified message at the non-fatal error level.

void rwsf::Logger::error ( const std::string &  message  ) 

Logs the specified message at the non-fatal error level.

void rwsf::Logger::fatal ( const rwsf::LogMessage message  ) 

Logs the specified message at the fatal level.

void rwsf::Logger::fatal ( const std::string &  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 rwsf::LogMessage message  ) 

Logs the specified message at the basic info level.

void rwsf::Logger::info ( const std::string &  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 rwsf::LogMessage message 
)

Logs the specified message at the given level.

void rwsf::Logger::log ( Logger::LogLevel  level,
const std::string &  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 rwsf::LogMessage message  ) 

Logs the specified message at the verbose level.

void rwsf::Logger::verbose ( const std::string &  message  ) 

Logs the specified message at the verbose level.

void rwsf::Logger::warn ( const rwsf::LogMessage message  ) 

Logs the specified message at the important warning level.

void rwsf::Logger::warn ( const std::string &  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 © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.