blocxx
|
#include <LogAppender.hpp>
Public Member Functions | |
virtual | ~LogAppender () |
void | logMessage (const LogMessage &message) const |
Log a message using the specified component and category. | |
bool | categoryIsEnabled (const String &category) const |
bool | componentAndCategoryAreEnabled (const String &component, const String &category) const |
ELogLevel | getLogLevel () const |
Static Public Member Functions | |
static LogAppenderRef | getCurrentLogAppender () |
Get a copy of the per thread LogAppenderRef or if not set, the default one. | |
static LogAppenderRef | getDefaultLogAppender () |
Returns a copy of default LogAppenderRef. | |
static bool | setDefaultLogAppender (const LogAppenderRef &ref) |
Set the default global LogAppenderRef. | |
static LogAppenderRef | getThreadLogAppender () |
Returns a copy of the thread LogAppenderRef. | |
static bool | setThreadLogAppender (const LogAppenderRef &ref) |
Set a per thread LogAppenderRef that overrides the default one. | |
static LogAppenderRef | createLogAppender (const String &name, const StringArray &components, const StringArray &categories, const String &messageFormat, const String &type, const LoggerConfigMap &configItems) |
Create a concrete log appender depending on the type string passed in. | |
Static Public Attributes | |
static const GlobalStringArray | ALL_COMPONENTS = BLOCXX_GLOBAL_STRING_INIT("*") |
Pass to createLogAppender to indicate all components. | |
static const GlobalStringArray | ALL_CATEGORIES = BLOCXX_GLOBAL_STRING_INIT("*") |
Pass to createLogAppender to indicate all categories. | |
static const GlobalString | STR_TTCC_MESSAGE_FORMAT = BLOCXX_GLOBAL_STRING_INIT("%r [%t] %-5p %c - %m") |
The Log4j TTCC message format - TTCC is acronym for Time Thread Category Component. | |
static const GlobalString | TYPE_SYSLOG = BLOCXX_GLOBAL_STRING_INIT("syslog") |
String of the type of the syslog log appender. | |
static const GlobalString | TYPE_STDERR = BLOCXX_GLOBAL_STRING_INIT("stderr") |
String of the type of the stderr log appender. | |
static const GlobalString | TYPE_FILE = BLOCXX_GLOBAL_STRING_INIT("file") |
String of the type of the file log appender. | |
static const GlobalString | TYPE_MPFILE = BLOCXX_GLOBAL_STRING_INIT("mpfile") |
String of the type of the multi-process file log appender. | |
static const GlobalString | TYPE_NULL = BLOCXX_GLOBAL_STRING_INIT("null") |
String of the type of the null log appender. | |
Protected Member Functions | |
LogAppender (const StringArray &components=ALL_COMPONENTS, const StringArray &categories=ALL_CATEGORIES, const String &pattern=STR_TTCC_MESSAGE_FORMAT) | |
Private Member Functions | |
virtual void | doProcessLogMessage (const String &formattedMessage, const LogMessage &message) const =0 |
Private Attributes | |
SortedVectorSet< String > | m_components |
bool | m_allComponents |
SortedVectorSet< String > | m_categories |
bool | m_allCategories |
LogMessagePatternFormatter | m_formatter |
ELogLevel | m_logLevel |
Definition at line 55 of file LogAppender.hpp.
BLOCXX_NAMESPACE::LogAppender::~LogAppender | ( | ) | [virtual] |
Definition at line 83 of file LogAppender.cpp.
BLOCXX_NAMESPACE::LogAppender::LogAppender | ( | const StringArray & | components = ALL_COMPONENTS , |
const StringArray & | categories = ALL_CATEGORIES , |
||
const String & | pattern = STR_TTCC_MESSAGE_FORMAT |
||
) | [protected] |
Definition at line 405 of file LogAppender.cpp.
References BLOCXX_ASSERTMSG, BLOCXX_NAMESPACE::E_ALL_LEVEL, BLOCXX_NAMESPACE::E_DEBUG2_LEVEL, BLOCXX_NAMESPACE::E_DEBUG3_LEVEL, BLOCXX_NAMESPACE::E_DEBUG_LEVEL, BLOCXX_NAMESPACE::E_ERROR_LEVEL, BLOCXX_NAMESPACE::E_FATAL_ERROR_LEVEL, BLOCXX_NAMESPACE::E_INFO_LEVEL, BLOCXX_NAMESPACE::E_NONE_LEVEL, BLOCXX_NAMESPACE::E_WARNING_LEVEL, BLOCXX_NAMESPACE::Logger::STR_DEBUG2_CATEGORY, BLOCXX_NAMESPACE::Logger::STR_DEBUG3_CATEGORY, BLOCXX_NAMESPACE::Logger::STR_DEBUG_CATEGORY, BLOCXX_NAMESPACE::Logger::STR_ERROR_CATEGORY, BLOCXX_NAMESPACE::Logger::STR_FATAL_CATEGORY, BLOCXX_NAMESPACE::Logger::STR_INFO_CATEGORY, and BLOCXX_NAMESPACE::Logger::STR_WARNING_CATEGORY.
bool BLOCXX_NAMESPACE::LogAppender::categoryIsEnabled | ( | const String & | category | ) | const |
Definition at line 275 of file LogAppender.cpp.
References BLOCXX_NAMESPACE::SortedVectorSet< T, Compare >::count(), m_allComponents, and m_components.
bool BLOCXX_NAMESPACE::LogAppender::componentAndCategoryAreEnabled | ( | const String & | component, |
const String & | category | ||
) | const |
Definition at line 282 of file LogAppender.cpp.
LogAppenderRef BLOCXX_NAMESPACE::LogAppender::createLogAppender | ( | const String & | name, |
const StringArray & | components, | ||
const StringArray & | categories, | ||
const String & | messageFormat, | ||
const String & | type, | ||
const LoggerConfigMap & | configItems | ||
) | [static] |
Create a concrete log appender depending on the type string passed in.
If type == "syslog" (TYPE_SYSLOG) a logger the writes to the syslog will be returned. If type == "" || type == "null" (TYPE_NULL) a logger that doesn't do anything will be returned. If type == "cerr" || type == "stderr" (TYPE_STDERR) a logger that writes to stderr will be returned. If type == "file" (TYPE_FILE) then a logger that writes to a file -- will be returned; the file name and other parameters are taken from configItems. If type == "mpfile" (TYPE_MPFILE) then a logger that writes to a file that may be shared with other process will be returned; the file name and other parameters are taken from configItems.
name | The name of the logger to create |
components | The message components the logger will log. "*" means all components. |
categories | The message categories the logger will log. "*" means all categories. |
type | The type of logger to create |
configItems | Additional config items the logger may use for configuration. |
LoggerException | - E_UNKNOWN_LOG_APPENDER_TYPE - if type is unkonwn.
|
Definition at line 308 of file LogAppender.cpp.
References BLOCXX_DEFAULT_LOG_1_FLUSH, BLOCXX_DEFAULT_LOG_1_MAX_BACKUP_INDEX, BLOCXX_DEFAULT_LOG_1_MAX_FILE_SIZE, BLOCXX_DEFAULT_LOG_1_SYSLOG_FACILITY, BLOCXX_DEFAULT_LOG_1_SYSLOG_IDENTITY, BLOCXX_THROW_ERR, BLOCXX_THROW_ERR_SUBEX, BLOCXX_NAMESPACE::String::c_str(), BLOCXX_NAMESPACE::Logger::E_INVALID_MAX_BACKUP_INDEX, BLOCXX_NAMESPACE::Logger::E_INVALID_MAX_FILE_SIZE, BLOCXX_NAMESPACE::Logger::E_UNKNOWN_LOG_APPENDER_TYPE, BLOCXX_NAMESPACE::String::empty(), BLOCXX_NAMESPACE::String::equalsIgnoreCase(), BLOCXX_NAMESPACE::Exception::getMessage(), BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_FLUSH_opt, BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_LOCATION_opt, BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_MAX_BACKUP_INDEX_opt, BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_MAX_FILE_SIZE_opt, BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_SYSLOG_FACILITY_opt, BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_SYSLOG_IDENTITY_opt, TYPE_FILE, TYPE_MPFILE, TYPE_NULL, TYPE_STDERR, and TYPE_SYSLOG.
virtual void BLOCXX_NAMESPACE::LogAppender::doProcessLogMessage | ( | const String & | formattedMessage, |
const LogMessage & | message | ||
) | const [private, pure virtual] |
LogAppenderRef BLOCXX_NAMESPACE::LogAppender::getCurrentLogAppender | ( | ) | [static] |
Get a copy of the per thread LogAppenderRef or if not set, the default one.
If neither setDefaultLogAppender() or setThreadLogAppender() has been called, the default LogAppender will be set to a NullAppender, and then returned.
This method is preferred over getDefaultLogAppender() or getThreadLogAppender().
Definition at line 137 of file LogAppender.cpp.
LogAppenderRef BLOCXX_NAMESPACE::LogAppender::getDefaultLogAppender | ( | ) | [static] |
Returns a copy of default LogAppenderRef.
If you want to get a log appender to log messages, you shouldn't call this function. Use getCurrentLogAppender() instead. If setDefaultLogAppender() hasn't been called, the default LogAppender will be set to a NullAppender, and then returned.
Definition at line 153 of file LogAppender.cpp.
ELogLevel BLOCXX_NAMESPACE::LogAppender::getLogLevel | ( | ) | const [inline] |
Definition at line 111 of file LogAppender.hpp.
LogAppenderRef BLOCXX_NAMESPACE::LogAppender::getThreadLogAppender | ( | ) | [static] |
Returns a copy of the thread LogAppenderRef.
If you want to get a log appender to log messages, you shouldn't call this function. Use getCurrentLogAppender() instead. If setThreadLogAppender() hasn't been called by the current thread, a null LogAppenderRef is returned.
Definition at line 185 of file LogAppender.cpp.
void BLOCXX_NAMESPACE::LogAppender::logMessage | ( | const LogMessage & | message | ) | const |
Log a message using the specified component and category.
message | The message to log |
Definition at line 263 of file LogAppender.cpp.
bool BLOCXX_NAMESPACE::LogAppender::setDefaultLogAppender | ( | const LogAppenderRef & | ref | ) | [static] |
Set the default global LogAppenderRef.
Each application that wants logging should call this function with the desired LogAppenderRef.
Definition at line 168 of file LogAppender.cpp.
bool BLOCXX_NAMESPACE::LogAppender::setThreadLogAppender | ( | const LogAppenderRef & | ref | ) | [static] |
Set a per thread LogAppenderRef that overrides the default one.
If a thread desires to use a different log appender than the default, it can call this function to set it.
ref | The appender that will be returned from subsequent calls to getCurrentLogAppender() or getThreadLogAppender() by the same thread. Pass a null to cause subsequent calls to getCurrentLogAppender() to return the global LogAppenderRef. |
Definition at line 216 of file LogAppender.cpp.
Referenced by BLOCXX_NAMESPACE::LogAppenderScope::LogAppenderScope(), and BLOCXX_NAMESPACE::LogAppenderScope::~LogAppenderScope().
const GlobalStringArray BLOCXX_NAMESPACE::LogAppender::ALL_CATEGORIES = BLOCXX_GLOBAL_STRING_INIT("*") [static] |
Pass to createLogAppender to indicate all categories.
Definition at line 155 of file LogAppender.hpp.
const GlobalStringArray BLOCXX_NAMESPACE::LogAppender::ALL_COMPONENTS = BLOCXX_GLOBAL_STRING_INIT("*") [static] |
Pass to createLogAppender to indicate all components.
Definition at line 153 of file LogAppender.hpp.
bool BLOCXX_NAMESPACE::LogAppender::m_allCategories [private] |
Definition at line 183 of file LogAppender.hpp.
bool BLOCXX_NAMESPACE::LogAppender::m_allComponents [private] |
Definition at line 181 of file LogAppender.hpp.
Referenced by categoryIsEnabled().
Definition at line 182 of file LogAppender.hpp.
Definition at line 180 of file LogAppender.hpp.
Referenced by categoryIsEnabled().
Definition at line 185 of file LogAppender.hpp.
Definition at line 187 of file LogAppender.hpp.
const GlobalString BLOCXX_NAMESPACE::LogAppender::STR_TTCC_MESSAGE_FORMAT = BLOCXX_GLOBAL_STRING_INIT("%r [%t] %-5p %c - %m") [static] |
The Log4j TTCC message format - TTCC is acronym for Time Thread Category Component.
"%r [%t] %-5p %c - %m"
Definition at line 158 of file LogAppender.hpp.
const GlobalString BLOCXX_NAMESPACE::LogAppender::TYPE_FILE = BLOCXX_GLOBAL_STRING_INIT("file") [static] |
String of the type of the file log appender.
Definition at line 164 of file LogAppender.hpp.
Referenced by createLogAppender().
const GlobalString BLOCXX_NAMESPACE::LogAppender::TYPE_MPFILE = BLOCXX_GLOBAL_STRING_INIT("mpfile") [static] |
String of the type of the multi-process file log appender.
Definition at line 166 of file LogAppender.hpp.
Referenced by createLogAppender().
const GlobalString BLOCXX_NAMESPACE::LogAppender::TYPE_NULL = BLOCXX_GLOBAL_STRING_INIT("null") [static] |
String of the type of the null log appender.
Definition at line 168 of file LogAppender.hpp.
Referenced by createLogAppender().
const GlobalString BLOCXX_NAMESPACE::LogAppender::TYPE_STDERR = BLOCXX_GLOBAL_STRING_INIT("stderr") [static] |
String of the type of the stderr log appender.
Definition at line 162 of file LogAppender.hpp.
Referenced by createLogAppender().
const GlobalString BLOCXX_NAMESPACE::LogAppender::TYPE_SYSLOG = BLOCXX_GLOBAL_STRING_INIT("syslog") [static] |
String of the type of the syslog log appender.
Definition at line 160 of file LogAppender.hpp.
Referenced by createLogAppender().