|
blocxx
|
#include <LogAppender.hpp>
Public Member Functions | |
| virtual | ~LogAppender () |
| void | logMessage (const LogMessage &message) const |
| Log a message using the specified component and category. More... | |
| 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. More... | |
| static LogAppenderRef | getDefaultLogAppender () |
| Returns a copy of default LogAppenderRef. More... | |
| static bool | setDefaultLogAppender (const LogAppenderRef &ref) |
| Set the default global LogAppenderRef. More... | |
| static LogAppenderRef | getThreadLogAppender () |
| Returns a copy of the thread LogAppenderRef. More... | |
| static bool | setThreadLogAppender (const LogAppenderRef &ref) |
| Set a per thread LogAppenderRef that overrides the default one. More... | |
| 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. More... | |
Static Public Attributes | |
| static const GlobalStringArray | ALL_COMPONENTS = { "*" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| Pass to createLogAppender to indicate all components. More... | |
| static const GlobalStringArray | ALL_CATEGORIES = { "*" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| Pass to createLogAppender to indicate all categories. More... | |
| 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. More... | |
| static const GlobalString | TYPE_SYSLOG = { "syslog" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the syslog log appender. More... | |
| static const GlobalString | TYPE_STDERR = { "stderr" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the stderr log appender. More... | |
| static const GlobalString | TYPE_FILE = { "file" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the file log appender. More... | |
| static const GlobalString | TYPE_MPFILE = { "mpfile" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the multi-process file log appender. More... | |
| static const GlobalString | TYPE_NULL = { "null" , 0, {0, PTHREAD_MUTEX_INITIALIZER} } |
| String of the type of the null log appender. More... | |
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 85 of file LogAppender.hpp.
|
virtual |
Definition at line 109 of file LogAppender.cpp.
|
protected |
Definition at line 431 of file LogAppender.cpp.
| bool BLOCXX_NAMESPACE::LogAppender::categoryIsEnabled | ( | const String & | category | ) | const |
Definition at line 301 of file LogAppender.cpp.
| bool BLOCXX_NAMESPACE::LogAppender::componentAndCategoryAreEnabled | ( | const String & | component, |
| const String & | category | ||
| ) | const |
Definition at line 308 of file LogAppender.cpp.
References BLOCXX_DEFAULT_LOG_1_SYSLOG_FACILITY, BLOCXX_DEFAULT_LOG_1_SYSLOG_IDENTITY, BLOCXX_NAMESPACE::String::empty(), BLOCXX_NAMESPACE::String::equalsIgnoreCase(), BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_LOCATION_opt, BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_SYSLOG_FACILITY_opt, BLOCXX_NAMESPACE::LogConfigOptions::LOG_1_SYSLOG_IDENTITY_opt, name, TYPE_FILE, TYPE_MPFILE, TYPE_NULL, TYPE_STDERR, and TYPE_SYSLOG.
|
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 334 of file LogAppender.cpp.
|
privatepure virtual |
|
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 163 of file LogAppender.cpp.
References BLOCXX_NAMESPACE::callOnce(), and BLOCXX_NAMESPACE::IntrusiveReference< T >::swap().
|
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 179 of file LogAppender.cpp.
References BLOCXX_NAMESPACE::callOnce().
|
inline |
Definition at line 171 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 211 of file LogAppender.cpp.
References BLOCXX_ASSERTMSG, BLOCXX_NAMESPACE::callOnce(), and BLOCXX_NAMESPACE::freeThreadLogAppender().
| 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 289 of file LogAppender.cpp.
References i.
|
static |
Set the default global LogAppenderRef.
Each application that wants logging should call this function with the desired LogAppenderRef.
Definition at line 194 of file LogAppender.cpp.
|
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 242 of file LogAppender.cpp.
|
static |
Pass to createLogAppender to indicate all categories.
Definition at line 215 of file LogAppender.hpp.
|
static |
Pass to createLogAppender to indicate all components.
Definition at line 213 of file LogAppender.hpp.
|
private |
Definition at line 243 of file LogAppender.hpp.
|
private |
Definition at line 241 of file LogAppender.hpp.
|
private |
Definition at line 242 of file LogAppender.hpp.
|
private |
Definition at line 240 of file LogAppender.hpp.
|
private |
Definition at line 245 of file LogAppender.hpp.
|
private |
Definition at line 247 of file LogAppender.hpp.
|
static |
The Log4j TTCC message format - TTCC is acronym for Time Thread Category Component.
"%r [%t] %-5p %c - %m"
Definition at line 218 of file LogAppender.hpp.
|
static |
String of the type of the file log appender.
Definition at line 224 of file LogAppender.hpp.
Referenced by componentAndCategoryAreEnabled().
|
static |
String of the type of the multi-process file log appender.
Definition at line 226 of file LogAppender.hpp.
Referenced by componentAndCategoryAreEnabled().
|
static |
String of the type of the null log appender.
Definition at line 228 of file LogAppender.hpp.
Referenced by componentAndCategoryAreEnabled().
|
static |
String of the type of the stderr log appender.
Definition at line 222 of file LogAppender.hpp.
Referenced by componentAndCategoryAreEnabled().
|
static |
String of the type of the syslog log appender.
Definition at line 220 of file LogAppender.hpp.
Referenced by componentAndCategoryAreEnabled().
1.8.18