#include <OW_Logger.hpp>
Inheritance diagram for OW_NAMESPACE::Logger:
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 | levelIsEnabled (const ELogLevel level) |
Check if the logger is enabled for given level. | |
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 Member Functions | |
static LoggerRef | getCurrentLogger () |
Get a copy of the per thread LoggerRef or if not set, the default one. | |
static LoggerRef | getDefaultLogger () |
Returns a copy of default LoggerRef. | |
static bool | setDefaultLogger (const LoggerRef &ref) |
Set the default global logger. | |
static bool | setThreadLogger (const LoggerRef &ref) |
Set a per thread Logger that overrides the default one. | |
static LoggerRef | createLogger (const String &type, bool debug) |
Create a concrete logger depending on the type string passed in. | |
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 () | |
Logger (const ELogLevel l) | |
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 &) | |
Logger & | operator= (const Logger &) |
void | swap (Logger &x) |
Private Member Functions | |
void | processLogMessage (const LogMessage &message) const |
Private Attributes | |
ELogLevel | m_logLevel |
String | m_defaultComponent |
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 OW_Logger.hpp.
|
Definition at line 86 of file OW_Logger.hpp. |
|
Definition at line 66 of file OW_Logger.cpp. |
|
Definition at line 71 of file OW_Logger.cpp. |
|
Definition at line 78 of file OW_Logger.cpp. |
|
Definition at line 85 of file OW_Logger.cpp. References m_defaultComponent, and OW_ASSERT. |
|
Definition at line 300 of file OW_Logger.cpp. |
|
Determine if the log category is enabled.
Definition at line 210 of file OW_Logger.cpp. References doCategoryIsEnabled(). Referenced by OW_NAMESPACE::AppenderLogger::doCategoryIsEnabled(). |
|
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 294 of file OW_Logger.cpp. References doClone(). |
|
Determine if the component and category are both enabled.
Definition at line 217 of file OW_Logger.cpp. References doComponentAndCategoryAreEnabled(). Referenced by OW_NAMESPACE::AppenderLogger::doComponentAndCategoryAreEnabled(). |
|
Create a concrete logger depending on the type string passed in. On Linux, if type == "syslog" a logger the writes to the syslog will be returned. If type == "" || type == "null" a logger that doesn't do anything will be returned. If type == "stderr" a logger that writes to stderr will be returned. Otherwise type is treated as a filename and a logger that writes to that file will be returned.
Definition at line 260 of file OW_Logger.cpp. References OW_NAMESPACE::LogAppender::ALL_CATEGORIES, OW_NAMESPACE::LogAppender::ALL_COMPONENTS, OW_NAMESPACE::LogAppender::createLogAppender(), OW_NAMESPACE::ConfigOpts::LOG_1_LOCATION_opt, name, OW_NAMESPACE::Array< T >::push_back(), STR_DEFAULT_COMPONENT, OW_NAMESPACE::LogMessagePatternFormatter::STR_DEFAULT_MESSAGE_PATTERN, type, OW_NAMESPACE::LogAppender::TYPE_FILE, OW_NAMESPACE::LogAppender::TYPE_NULL, OW_NAMESPACE::LogAppender::TYPE_STDERR, and OW_NAMESPACE::LogAppender::TYPE_SYSLOG. |
|
Return whether logging is enabled for the category. Default implementation always returns true. Reimplemented in OW_NAMESPACE::AppenderLogger. Definition at line 231 of file OW_Logger.cpp. Referenced by categoryIsEnabled(). |
|
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)); } Implemented in OW_NAMESPACE::AppenderLogger, OW_NAMESPACE::CerrLogger, and OW_NAMESPACE::NullLogger. Referenced by clone(). |
|
Return whether logging is enabled for the component and category. Default implementation always returns true. Reimplemented in OW_NAMESPACE::AppenderLogger. Definition at line 224 of file OW_Logger.cpp. Referenced by componentAndCategoryAreEnabled(). |
|
Output the message. Calls will not be serialized, so the derived class' implementation must be thread safe. Implemented in OW_NAMESPACE::AppenderLogger, OW_NAMESPACE::CerrLogger, and OW_NAMESPACE::NullLogger. Referenced by processLogMessage(). |
|
Get a copy of the per thread LoggerRef or if not set, the default one. If neither setDefaultLogger() or setThreadLogger() has been called, the default logger will be set to a NullLogger, and then returned. Definition at line 416 of file OW_Logger.cpp. References OW_NAMESPACE::callOnce(), OW_NAMESPACE::g_loggerKey, OW_NAMESPACE::g_onceGuard, getDefaultLogger(), and OW_NAMESPACE::initGuardAndKey(). |
|
Gets the default component.
Definition at line 246 of file OW_Logger.cpp. References m_defaultComponent. |
|
Returns a copy of default LoggerRef. If you want to log messages, you shouldn't call this function. Use getCurrentLogger() instead. If setDefaultLogger() hasn't been called, the default logger will be set to a NullLogger, and then returned. Definition at line 401 of file OW_Logger.cpp. References OW_NAMESPACE::callOnce(), OW_NAMESPACE::g_defaultLogger, OW_NAMESPACE::g_mutexGuard, OW_NAMESPACE::g_onceGuard, and OW_NAMESPACE::initGuardAndKey(). Referenced by getCurrentLogger(). |
|
Definition at line 218 of file OW_Logger.hpp. Referenced by OW_NAMESPACE::AppenderLogger::getLevel(), and levelIsEnabled(). |
|
Check if the logger is enabled for given level.
Definition at line 432 of file OW_Logger.cpp. References getLogLevel(). |
|
If getLogLevel() >= E_DEBUG_LEVEL, Log debug info.
Definition at line 165 of file OW_Logger.cpp. References OW_NAMESPACE::E_DEBUG_LEVEL, m_defaultComponent, m_logLevel, processLogMessage(), and STR_DEBUG_CATEGORY. |
|
If getLogLevel() >= E_ERROR_LEVEL, Log message with an error category and the default component.
Definition at line 145 of file OW_Logger.cpp. References OW_NAMESPACE::E_ERROR_LEVEL, m_defaultComponent, m_logLevel, processLogMessage(), and STR_ERROR_CATEGORY. |
|
Log message with a fatal error category and the default component.
Definition at line 135 of file OW_Logger.cpp. References OW_NAMESPACE::E_FATAL_ERROR_LEVEL, m_defaultComponent, m_logLevel, processLogMessage(), and STR_FATAL_CATEGORY. |
|
If getLogLevel() >= E_INFO_LEVEL, Log info.
Definition at line 155 of file OW_Logger.cpp. References OW_NAMESPACE::E_INFO_LEVEL, m_defaultComponent, m_logLevel, processLogMessage(), and STR_INFO_CATEGORY. |
|
Log a message. The current log level is ignored.
Definition at line 203 of file OW_Logger.cpp. References processLogMessage(). |
|
Log a message using the default component and specified category. The current log level is ignored.
Definition at line 196 of file OW_Logger.cpp. References m_defaultComponent, and processLogMessage(). |
|
Log a message using the default component and specified category. The current log level is ignored.
Definition at line 189 of file OW_Logger.cpp. References m_defaultComponent, and processLogMessage(). |
|
Log a message using the specified component and category The current log level is ignored.
Definition at line 182 of file OW_Logger.cpp. References processLogMessage(). |
|
Log a message using the specified component and category The current log level is ignored.
Definition at line 175 of file OW_Logger.cpp. References processLogMessage(). Referenced by OW_NAMESPACE::AppenderLogger::doProcessLogMessage(). |
|
Definition at line 310 of file OW_Logger.cpp. References m_defaultComponent, and m_logLevel. |
|
Definition at line 94 of file OW_Logger.cpp. References OW_NAMESPACE::LogMessage::category, OW_NAMESPACE::LogMessage::component, doProcessLogMessage(), OW_NAMESPACE::String::empty(), OW_NAMESPACE::LogMessage::message, and OW_ASSERT. Referenced by logDebug(), logError(), logFatalError(), logInfo(), and logMessage(). |
|
Sets the default component. This function is not thread safe.
Definition at line 238 of file OW_Logger.cpp. References m_defaultComponent, and OW_ASSERT. |
|
Set the default global logger.
Definition at line 359 of file OW_Logger.cpp. References OW_NAMESPACE::callOnce(), OW_NAMESPACE::g_defaultLogger, OW_NAMESPACE::g_mutexGuard, OW_NAMESPACE::g_onceGuard, and OW_NAMESPACE::initGuardAndKey(). |
|
Set the log level. All lower level log messages will be ignored. This function is not thread safe.
Definition at line 105 of file OW_Logger.cpp. References OW_NAMESPACE::E_INFO_LEVEL, OW_NAMESPACE::String::equalsIgnoreCase(), setLogLevel(), and STR_INFO_CATEGORY. |
|
Set the log level. All lower level log messages will be ignored. This function is not thread safe.
Definition at line 253 of file OW_Logger.cpp. References m_logLevel. Referenced by setLogLevel(). |
|
Set a per thread Logger that overrides the default one.
Definition at line 376 of file OW_Logger.cpp. References OW_NAMESPACE::callOnce(), OW_NAMESPACE::freeThreadLogger(), OW_NAMESPACE::g_loggerKey, OW_NAMESPACE::g_onceGuard, OW_NAMESPACE::initGuardAndKey(), and OW_ASSERTMSG. |
|
Definition at line 319 of file OW_Logger.cpp. References m_defaultComponent, m_logLevel, OW_NAMESPACE::String::swap(), and OW_NAMESPACE::swap(). |
|
Definition at line 333 of file OW_Logger.hpp. Referenced by getDefaultComponent(), logDebug(), logError(), logFatalError(), Logger(), logInfo(), logMessage(), operator=(), setDefaultComponent(), and swap(). |
|
Definition at line 332 of file OW_Logger.hpp. Referenced by logDebug(), logError(), logFatalError(), logInfo(), operator=(), setLogLevel(), and swap(). |
|
Definition at line 83 of file OW_Logger.hpp. |
|
Definition at line 82 of file OW_Logger.hpp. Referenced by OW_NAMESPACE::EmbeddedCIMOMEnvironment::_createLogger(), OW_NAMESPACE::CIMOMEnvironment::_createLogger(), OW_NAMESPACE::SyslogAppender::doProcessLogMessage(), OW_NAMESPACE::LogAppender::getLogLevel(), and logDebug(). |
|
Definition at line 84 of file OW_Logger.hpp. Referenced by createLogger(). |
|
Definition at line 80 of file OW_Logger.hpp. Referenced by OW_NAMESPACE::EmbeddedCIMOMEnvironment::_createLogger(), OW_NAMESPACE::CIMOMEnvironment::_createLogger(), OW_NAMESPACE::SyslogAppender::doProcessLogMessage(), OW_NAMESPACE::LogAppender::getLogLevel(), and logError(). |
|
Definition at line 79 of file OW_Logger.hpp. Referenced by OW_NAMESPACE::EmbeddedCIMOMEnvironment::_createLogger(), OW_NAMESPACE::CIMOMEnvironment::_createLogger(), OW_NAMESPACE::SyslogAppender::doProcessLogMessage(), OW_NAMESPACE::LogAppender::getLogLevel(), and logFatalError(). |
|
Definition at line 81 of file OW_Logger.hpp. Referenced by OW_NAMESPACE::EmbeddedCIMOMEnvironment::_createLogger(), OW_NAMESPACE::CIMOMEnvironment::_createLogger(), OW_NAMESPACE::SyslogAppender::doProcessLogMessage(), OW_NAMESPACE::LogAppender::getLogLevel(), logInfo(), and setLogLevel(). |
|
Definition at line 78 of file OW_Logger.hpp. |