|
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 = { "*" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| Pass to createLogAppender to indicate all components. | |
| static const GlobalStringArray | ALL_CATEGORIES = { "*" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| Pass to createLogAppender to indicate all categories. | |
| static const GlobalString | STR_TTCC_MESSAGE_FORMAT = { "%r [%t] %-5p %c - %m" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| The Log4j TTCC message format - TTCC is acronym for Time Thread Category Component. | |
| static const GlobalString | TYPE_SYSLOG = { "syslog" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the syslog log appender. | |
| static const GlobalString | TYPE_STDERR = { "stderr" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the stderr log appender. | |
| static const GlobalString | TYPE_FILE = { "file" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the file log appender. | |
| static const GlobalString | TYPE_MPFILE = { "mpfile" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the multi-process file log appender. | |
| static const GlobalString | TYPE_NULL = { "null" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| 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) | |
Protected Member Functions inherited from BLOCXX_NAMESPACE::IntrusiveCountableBase | |
| IntrusiveCountableBase () | |
| IntrusiveCountableBase (const IntrusiveCountableBase &) | |
| IntrusiveCountableBase & | operator= (const IntrusiveCountableBase &) |
| virtual | ~IntrusiveCountableBase () |
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.
|
virtual |
Definition at line 79 of file LogAppender.cpp.
|
protected |
Definition at line 401 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, m_allCategories, m_allComponents, m_categories, m_components, m_logLevel, BLOCXX_NAMESPACE::operator==(), 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.
Definition at line 271 of file LogAppender.cpp.
References m_allCategories, and m_categories.
Referenced by BLOCXX_NAMESPACE::Logger::categoryIsEnabled(), and componentAndCategoryAreEnabled().
| bool BLOCXX_NAMESPACE::LogAppender::componentAndCategoryAreEnabled | ( | const String & | component, |
| const String & | category ) const |
Definition at line 278 of file LogAppender.cpp.
References categoryIsEnabled(), m_allComponents, and m_components.
Referenced by BLOCXX_NAMESPACE::Logger::componentAndCategoryAreEnabled(), and logMessage().
|
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 304 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::Format::c_str(), 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::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, name, BLOCXX_NAMESPACE::operator==(), TYPE_FILE, TYPE_MPFILE, TYPE_NULL, TYPE_STDERR, and TYPE_SYSLOG.
|
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 133 of file LogAppender.cpp.
References getDefaultLogAppender(), getThreadLogAppender(), and BLOCXX_NAMESPACE::operator==().
|
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 149 of file LogAppender.cpp.
References BLOCXX_NAMESPACE::callOnce(), and BLOCXX_NAMESPACE::operator==().
Referenced by getCurrentLogAppender().
|
inline |
Definition at line 111 of file LogAppender.hpp.
|
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 181 of file LogAppender.cpp.
References BLOCXX_NAMESPACE::callOnce(), and BLOCXX_NAMESPACE::operator==().
Referenced by getCurrentLogAppender().
| 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 259 of file LogAppender.cpp.
References BLOCXX_NAMESPACE::LogMessage::category, BLOCXX_NAMESPACE::LogMessage::component, componentAndCategoryAreEnabled(), doProcessLogMessage(), BLOCXX_NAMESPACE::LogMessagePatternFormatter::formatMessage(), m_formatter, and BLOCXX_NAMESPACE::operator==().
Referenced by BLOCXX_NAMESPACE::MultiAppender::doProcessLogMessage(), and BLOCXX_NAMESPACE::Logger::processLogMessage().
|
static |
Set the default global LogAppenderRef.
Each application that wants logging should call this function with the desired LogAppenderRef.
Definition at line 164 of file LogAppender.cpp.
References BLOCXX_NAMESPACE::callOnce(), BLOCXX_NAMESPACE::operator==(), and BLOCXX_NAMESPACE::IntrusiveReference< T >::swap().
|
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 212 of file LogAppender.cpp.
References BLOCXX_ASSERTMSG, BLOCXX_NAMESPACE::callOnce(), BLOCXX_NAMESPACE::freeThreadLogAppender(), and BLOCXX_NAMESPACE::operator==().
Referenced by BLOCXX_NAMESPACE::LogAppenderScope::LogAppenderScope(), and BLOCXX_NAMESPACE::LogAppenderScope::~LogAppenderScope().
|
static |
Pass to createLogAppender to indicate all categories.
Definition at line 155 of file LogAppender.hpp.
|
static |
Pass to createLogAppender to indicate all components.
Definition at line 153 of file LogAppender.hpp.
|
private |
Definition at line 183 of file LogAppender.hpp.
Referenced by categoryIsEnabled(), and LogAppender().
|
private |
Definition at line 181 of file LogAppender.hpp.
Referenced by componentAndCategoryAreEnabled(), and LogAppender().
|
private |
Definition at line 182 of file LogAppender.hpp.
Referenced by categoryIsEnabled(), and LogAppender().
|
private |
Definition at line 180 of file LogAppender.hpp.
Referenced by componentAndCategoryAreEnabled(), and LogAppender().
|
private |
Definition at line 185 of file LogAppender.hpp.
Referenced by logMessage().
|
private |
Definition at line 187 of file LogAppender.hpp.
Referenced by LogAppender().
|
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.
|
static |
String of the type of the file log appender.
Definition at line 164 of file LogAppender.hpp.
Referenced by createLogAppender().
|
static |
String of the type of the multi-process file log appender.
Definition at line 166 of file LogAppender.hpp.
Referenced by createLogAppender().
|
static |
String of the type of the null log appender.
Definition at line 168 of file LogAppender.hpp.
Referenced by createLogAppender().
|
static |
String of the type of the stderr log appender.
Definition at line 162 of file LogAppender.hpp.
Referenced by createLogAppender().
|
static |
String of the type of the syslog log appender.
Definition at line 160 of file LogAppender.hpp.
Referenced by createLogAppender().