OWBI1::Logger Class Reference

Logging interface. More...

#include <OWBI1_Logger.hpp>

Inheritance diagram for OWBI1::Logger:

Inheritance graph
[legend]
Collaboration diagram for OWBI1::Logger:

Collaboration graph
[legend]
List of all members.

Public Types

enum  ELoggerErrorCodes { E_UNKNOWN_LOG_APPENDER_TYPE, E_INVALID_MAX_FILE_SIZE, E_INVALID_MAX_BACKUP_INDEX }

Public Member Functions

void logFatalError (const String &message, const char *filename=0, int fileline=-1, const char *methodname=0) const
 Log message with a fatal error category and the default component.
void logError (const String &message, const char *filename=0, int fileline=-1, const char *methodname=0) const
 If getLogLevel() >= E_ERROR_LEVEL, Log message with an error category and the default component.
void logInfo (const String &message, const char *filename=0, int fileline=-1, const char *methodname=0) const
 If getLogLevel() >= E_INFO_LEVEL, Log info.
void logDebug (const String &message, const char *filename=0, int fileline=-1, const char *methodname=0) const
 If getLogLevel() >= E_DEBUG_LEVEL, Log debug info.
void logMessage (const String &component, const String &category, const String &message) const
 Log a message using the specified component and category The current log level is ignored.
void logMessage (const String &component, const String &category, const String &message, const char *filename, int fileline, const char *methodname) const
 Log a message using the specified component and category The current log level is ignored.
void logMessage (const String &category, const String &message) const
 Log a message using the default component and specified category.
void logMessage (const String &category, const String &message, const char *filename, int fileline, const char *methodname) const
 Log a message using the default component and specified category.
void logMessage (const LogMessage &message) const
 Log a message.
void setDefaultComponent (const String &component)
 Sets the default component.
String getDefaultComponent () const
 Gets the default component.
ELogLevel getLogLevel () const
void setLogLevel (ELogLevel logLevel)
 Set the log level.
void setLogLevel (const String &logLevel)
 Set the log level.
bool categoryIsEnabled (const String &category) const
 Determine if the log category is enabled.
bool componentAndCategoryAreEnabled (const String &component, const String &category) const
 Determine if the component and category are both enabled.
LoggerRef clone () const
 Make a copy of the derived instance.
virtual ~Logger ()

Static Public Attributes

static const String STR_NONE_CATEGORY
static const String STR_FATAL_CATEGORY
static const String STR_ERROR_CATEGORY
static const String STR_INFO_CATEGORY
static const String STR_DEBUG_CATEGORY
static const String STR_ALL_CATEGORY
static const String STR_DEFAULT_COMPONENT

Protected Member Functions

 Logger (const String &defaultComponent, const ELogLevel logLevel)
virtual void doProcessLogMessage (const LogMessage &message) const =0
 Output the message.
virtual bool doCategoryIsEnabled (const String &category) const
 Return whether logging is enabled for the category.
virtual bool doComponentAndCategoryAreEnabled (const String &component, const String &category) const
 Return whether logging is enabled for the component and category.
virtual LoggerRef doClone () const =0
 Make a copy of the derived instance.
 Logger (const Logger &)
Loggeroperator= (const Logger &)
void swap (Logger &x)

Private Member Functions

void processLogMessage (const LogMessage &message) const

Private Attributes

ELogLevel m_logLevel
String m_defaultComponent

Detailed Description

Logging interface.

Used to output log messages. A Logger has a component and a log level. The component will be used for all log messages generated, unless another component explicitly specified in a call to logMessage().

Invariants:

Responsibilities:

Collaborators:

Thread safety: read/write, except for setDefaultComponent() and setLogLevel() which should only be called during initialization phase.

Copy semantics: Non-copyable

Exception safety: Strong

Definition at line 74 of file OWBI1_Logger.hpp.


Member Enumeration Documentation

enum OWBI1::Logger::ELoggerErrorCodes
 

Enumerator:
E_UNKNOWN_LOG_APPENDER_TYPE 
E_INVALID_MAX_FILE_SIZE 
E_INVALID_MAX_BACKUP_INDEX 

Definition at line 86 of file OWBI1_Logger.hpp.


Constructor & Destructor Documentation

OWBI1::Logger::~Logger  )  [virtual]
 

Definition at line 57 of file OWBI1_Logger.cpp.

OWBI1::Logger::Logger const String defaultComponent,
const ELogLevel  logLevel
[protected]
 

Parameters:
defaultComponent The component used for log messages (can be overridden my logMessage())
logLevel The log level. All lower level log messages will be ignored.

Definition at line 62 of file OWBI1_Logger.cpp.

References m_defaultComponent, and OW_ASSERT.

OWBI1::Logger::Logger const Logger  )  [protected]
 

Definition at line 243 of file OWBI1_Logger.cpp.


Member Function Documentation

bool OWBI1::Logger::categoryIsEnabled const String category  )  const
 

Determine if the log category is enabled.

Definition at line 187 of file OWBI1_Logger.cpp.

References doCategoryIsEnabled().

LoggerRef OWBI1::Logger::clone  )  const
 

Make a copy of the derived instance.

Provided the derived class has a suitable copy constructor, an implementation of clone should simply be: LoggerRef DerivedLogger::doClone() const { return LoggerRef(new DerivedLogger(*this)); }

Definition at line 237 of file OWBI1_Logger.cpp.

References doClone().

bool OWBI1::Logger::componentAndCategoryAreEnabled const String component,
const String category
const
 

Determine if the component and category are both enabled.

Definition at line 194 of file OWBI1_Logger.cpp.

References doComponentAndCategoryAreEnabled().

bool OWBI1::Logger::doCategoryIsEnabled const String category  )  const [protected, virtual]
 

Return whether logging is enabled for the category.

Default implementation always returns true.

Definition at line 208 of file OWBI1_Logger.cpp.

Referenced by categoryIsEnabled().

virtual LoggerRef OWBI1::Logger::doClone  )  const [protected, pure virtual]
 

Make a copy of the derived instance.

Provided the derived class has a suitable copy constructor, an implementation of clone should simply be: LoggerRef DerivedLogger::doClone() const { return LoggerRef(new DerivedLogger(*this)); }

Referenced by clone().

bool OWBI1::Logger::doComponentAndCategoryAreEnabled const String component,
const String category
const [protected, virtual]
 

Return whether logging is enabled for the component and category.

Default implementation always returns true.

Definition at line 201 of file OWBI1_Logger.cpp.

Referenced by componentAndCategoryAreEnabled().

virtual void OWBI1::Logger::doProcessLogMessage const LogMessage message  )  const [protected, pure virtual]
 

Output the message.

Calls will not be serialized, so the derived class' implementation must be thread safe.

Referenced by processLogMessage().

String OWBI1::Logger::getDefaultComponent  )  const
 

Gets the default component.

Returns:
The default component

Definition at line 223 of file OWBI1_Logger.cpp.

References m_defaultComponent.

ELogLevel OWBI1::Logger::getLogLevel  )  const [inline]
 

Returns:
The current log level

Definition at line 192 of file OWBI1_Logger.hpp.

void OWBI1::Logger::logDebug const String message,
const char *  filename = 0,
int  fileline = -1,
const char *  methodname = 0
const
 

If getLogLevel() >= E_DEBUG_LEVEL, Log debug info.

Parameters:
message The string to log.
filename The file where the log statement was written.
fileline The line number of the file where the log statement was written.
methodname The method name where the log statement was written.

Definition at line 142 of file OWBI1_Logger.cpp.

References OWBI1::E_DEBUG_LEVEL, m_defaultComponent, m_logLevel, processLogMessage(), and STR_DEBUG_CATEGORY.

void OWBI1::Logger::logError const String message,
const char *  filename = 0,
int  fileline = -1,
const char *  methodname = 0
const
 

If getLogLevel() >= E_ERROR_LEVEL, Log message with an error category and the default component.

Parameters:
message The string to log.
filename The file where the log statement was written.
fileline The line number of the file where the log statement was written.
methodname The method name where the log statement was written.

Definition at line 122 of file OWBI1_Logger.cpp.

References OWBI1::E_ERROR_LEVEL, m_defaultComponent, m_logLevel, processLogMessage(), and STR_ERROR_CATEGORY.

void OWBI1::Logger::logFatalError const String message,
const char *  filename = 0,
int  fileline = -1,
const char *  methodname = 0
const
 

Log message with a fatal error category and the default component.

Parameters:
message The string to log.
filename The file where the log statement was written.
fileline The line number of the file where the log statement was written.
methodname The method name where the log statement was written.

Definition at line 112 of file OWBI1_Logger.cpp.

References OWBI1::E_FATAL_ERROR_LEVEL, m_defaultComponent, m_logLevel, processLogMessage(), and STR_FATAL_CATEGORY.

void OWBI1::Logger::logInfo const String message,
const char *  filename = 0,
int  fileline = -1,
const char *  methodname = 0
const
 

If getLogLevel() >= E_INFO_LEVEL, Log info.

Parameters:
message The string to log.
filename The file where the log statement was written.
fileline The line number of the file where the log statement was written.
methodname The method name where the log statement was written.

Definition at line 132 of file OWBI1_Logger.cpp.

References OWBI1::E_INFO_LEVEL, m_defaultComponent, m_logLevel, processLogMessage(), and STR_INFO_CATEGORY.

void OWBI1::Logger::logMessage const LogMessage message  )  const
 

Log a message.

The current log level is ignored.

Parameters:
message The message to log

Definition at line 180 of file OWBI1_Logger.cpp.

References processLogMessage().

void OWBI1::Logger::logMessage const String category,
const String message,
const char *  filename,
int  fileline,
const char *  methodname
const
 

Log a message using the default component and specified category.

The current log level is ignored.

Parameters:
category The category of the log message.
message The message to log
filename The file where the log statement was written.
fileline The line number of the file where the log statement was written.
methodname The method name where the log statement was written.

Definition at line 173 of file OWBI1_Logger.cpp.

References m_defaultComponent, and processLogMessage().

void OWBI1::Logger::logMessage const String category,
const String message
const
 

Log a message using the default component and specified category.

The current log level is ignored.

Parameters:
category The category of the log message.
message The message to log

Definition at line 166 of file OWBI1_Logger.cpp.

References m_defaultComponent, and processLogMessage().

void OWBI1::Logger::logMessage const String component,
const String category,
const String message,
const char *  filename,
int  fileline,
const char *  methodname
const
 

Log a message using the specified component and category The current log level is ignored.

Parameters:
component The component generating the log message.
category The category of the log message.
message The message to log
filename The file where the log statement was written.
fileline The line number of the file where the log statement was written.
methodname The method name where the log statement was written.

Definition at line 159 of file OWBI1_Logger.cpp.

References processLogMessage().

void OWBI1::Logger::logMessage const String component,
const String category,
const String message
const
 

Log a message using the specified component and category The current log level is ignored.

Parameters:
component The component generating the log message.
category The category of the log message.
message The message to log

Definition at line 152 of file OWBI1_Logger.cpp.

References processLogMessage().

Logger & OWBI1::Logger::operator= const Logger  )  [protected]
 

Definition at line 253 of file OWBI1_Logger.cpp.

References m_defaultComponent, and m_logLevel.

void OWBI1::Logger::processLogMessage const LogMessage message  )  const [private]
 

Definition at line 71 of file OWBI1_Logger.cpp.

References OWBI1::LogMessage::category, OWBI1::LogMessage::component, doProcessLogMessage(), OWBI1::String::empty(), OWBI1::LogMessage::message, and OW_ASSERT.

Referenced by logDebug(), logError(), logFatalError(), logInfo(), and logMessage().

void OWBI1::Logger::setDefaultComponent const String component  ) 
 

Sets the default component.

This function is not thread safe.

Parameters:
component The new default component

Definition at line 215 of file OWBI1_Logger.cpp.

References m_defaultComponent, and OW_ASSERT.

void OWBI1::Logger::setLogLevel const String logLevel  ) 
 

Set the log level.

All lower level log messages will be ignored. This function is not thread safe.

Parameters:
logLevel The log level, valid values: { STR_FATAL_ERROR_CATEGORY, STR_ERROR_CATEGORY, STR_INFO_CATEGORY, STR_DEBUG_CATEGORY }. Case-insensitive. If logLevel is unknown, the level will be set to E_FATAL_ERROR_LEVEL

Definition at line 82 of file OWBI1_Logger.cpp.

References OWBI1::E_INFO_LEVEL, OWBI1::String::equalsIgnoreCase(), setLogLevel(), and STR_INFO_CATEGORY.

void OWBI1::Logger::setLogLevel ELogLevel  logLevel  ) 
 

Set the log level.

All lower level log messages will be ignored. This function is not thread safe.

Parameters:
logLevel the level as an enumeration value.

Definition at line 230 of file OWBI1_Logger.cpp.

References m_logLevel.

Referenced by setLogLevel().

void OWBI1::Logger::swap Logger x  )  [protected]
 

Definition at line 262 of file OWBI1_Logger.cpp.

References m_defaultComponent, m_logLevel, OWBI1::String::swap(), and OW_NAMESPACE::swap().


Member Data Documentation

String OWBI1::Logger::m_defaultComponent [private]
 

Definition at line 282 of file OWBI1_Logger.hpp.

Referenced by getDefaultComponent(), logDebug(), logError(), logFatalError(), Logger(), logInfo(), logMessage(), operator=(), setDefaultComponent(), and swap().

ELogLevel OWBI1::Logger::m_logLevel [private]
 

Definition at line 281 of file OWBI1_Logger.hpp.

Referenced by logDebug(), logError(), logFatalError(), logInfo(), operator=(), setLogLevel(), and swap().

const String OWBI1::Logger::STR_ALL_CATEGORY [static]
 

Definition at line 83 of file OWBI1_Logger.hpp.

const String OWBI1::Logger::STR_DEBUG_CATEGORY [static]
 

Definition at line 82 of file OWBI1_Logger.hpp.

Referenced by logDebug().

const String OWBI1::Logger::STR_DEFAULT_COMPONENT [static]
 

Definition at line 84 of file OWBI1_Logger.hpp.

const String OWBI1::Logger::STR_ERROR_CATEGORY [static]
 

Definition at line 80 of file OWBI1_Logger.hpp.

Referenced by logError().

const String OWBI1::Logger::STR_FATAL_CATEGORY [static]
 

Definition at line 79 of file OWBI1_Logger.hpp.

Referenced by logFatalError().

const String OWBI1::Logger::STR_INFO_CATEGORY [static]
 

Definition at line 81 of file OWBI1_Logger.hpp.

Referenced by logInfo(), and setLogLevel().

const String OWBI1::Logger::STR_NONE_CATEGORY [static]
 

Definition at line 78 of file OWBI1_Logger.hpp.


The documentation for this class was generated from the following files:
Generated on Thu Feb 9 09:18:32 2006 for openwbem by  doxygen 1.4.6