Go to the documentation of this file.
39 #include "blocxx/BLOCXX_config.h"
97 OnceFlag g_onceGuard = BLOCXX_ONCE_INIT;
98 NonRecursiveMutex* g_mutexGuard = NULL;
100 struct NullAppenderFactory
111 void initGuardAndKey()
115 LPVOID thread_data = NULL;
116 BOOL ret = TlsSetValue(dwTlsIndex, thread_data)
136 if(threadLogAppender)
138 return threadLogAppender;
151 callOnce(g_onceGuard, initGuardAndKey);
152 NonRecursiveMutexLock lock(*g_mutexGuard);
157 return *g_defaultLogAppender;
168 callOnce(g_onceGuard, initGuardAndKey);
183 callOnce(g_onceGuard, initGuardAndKey);
189 pthread_addr_t addr_ptr = NULL;
190 int ret = pthread_getspecific(g_loggerKey, &addr_ptr);
196 ptr =
static_cast<LogAppenderRef *
>(pthread_getspecific(g_loggerKey));
214 callOnce(g_onceGuard, initGuardAndKey);
228 if (!(ret = TlsSetValue(dwTlsIndex, ptr)))
237 pthread_addr_t addr_ptr = NULL;
238 pthread_getspecific(g_loggerKey, &addr_ptr);
240 int ret = pthread_setspecific(g_loggerKey, ptr);
245 int ret = pthread_setspecific(g_loggerKey, ptr);
288 getConfigItem(
const LoggerConfigMap& configItems,
const String &itemName,
const String& defRetVal =
"")
291 if (
i != configItems.end())
315 appender =
new NullAppender(components, categories, messageFormat);
323 appender =
new SyslogAppender(components, categories, messageFormat, identity, facility);
328 appender =
new CerrAppender(components, categories, messageFormat);
333 String filename = getConfigItem(configItems, configItem);
335 UInt64 maxFileSize(0);
348 unsigned int maxBackupIndex(0);
354 catch (StringConversionException& e)
368 ).equalsIgnoreCase(
"true");
369 appender =
new FileAppender(
370 components, categories, filename.
c_str(), messageFormat,
371 maxFileSize, maxBackupIndex, flushLog
376 appender =
new MultiProcessFileAppender(
377 components, categories, filename, messageFormat,
378 maxFileSize, maxBackupIndex
402 : m_components(components.begin(), components.end())
403 , m_categories(categories.begin(), categories.end())
419 int nonLevelCategoryCount = numCategories - debug3Count - debug2Count - debugCount - infoCount - warningCount - errorCount - fatalCount;
421 if (numCategories == 0)
429 else if (debug3Count > 0)
433 else if (debug2Count > 0)
437 else if (debugCount > 0)
441 else if (infoCount > 0)
445 else if (warningCount > 0)
449 else if (errorCount > 0)
453 else if (fatalCount > 0)
459 BLOCXX_ASSERTMSG(0,
"Internal error. LogAppender unable to determine log level!");
void swap(IntrusiveReference &rhs)
char const LOG_1_SYSLOG_IDENTITY_opt[]
static LogAppenderRef getDefaultLogAppender()
Returns a copy of default LogAppenderRef.
LogAppender(const StringArray &components=ALL_COMPONENTS, const StringArray &categories=ALL_CATEGORIES, const String &pattern=STR_TTCC_MESSAGE_FORMAT)
This class can be used to store a global pointer.
static const GlobalString STR_TTCC_MESSAGE_FORMAT
The Log4j TTCC message format - TTCC is acronym for Time Thread Category Component.
char const LOG_1_FLUSH_opt[]
#define BLOCXX_DEFAULT_LOG_1_MAX_BACKUP_INDEX
static const GlobalString TYPE_SYSLOG
String of the type of the syslog log appender.
SortedVectorMap< String, String > LoggerConfigMap
static const GlobalString STR_WARNING_CATEGORY
static LogAppenderRef getCurrentLogAppender()
Get a copy of the per thread LogAppenderRef or if not set, the default one.
char const LOG_1_MAX_FILE_SIZE_opt[]
This class sends log messges to syslog.
#define BLOCXX_DEFAULT_LOG_1_MAX_FILE_SIZE
virtual void doProcessLogMessage(const String &formattedMessage, const LogMessage &message) const =0
This String class is an abstract data type that represents as NULL terminated string of characters.
static const GlobalStringArray ALL_COMPONENTS
Pass to createLogAppender to indicate all components.
The CerrAppender is a LogAppender derivative that sends log message to stderr.
This class sends log messges to the bit bucket.
static const GlobalString TYPE_FILE
String of the type of the file log appender.
static const GlobalString STR_INFO_CATEGORY
static LogAppenderRef getThreadLogAppender()
Returns a copy of the thread LogAppenderRef.
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
virtual const char * getMessage() const
Returns the message.
static const GlobalString STR_DEBUG3_CATEGORY
SortedVectorSet< String > m_components
LazyGlobal< String, char const *const > GlobalString
@ E_INVALID_MAX_BACKUP_INDEX
static const GlobalString STR_FATAL_CATEGORY
#define BLOCXX_DEFAULT_LOG_1_SYSLOG_FACILITY
#define BLOCXX_ASSERTMSG(CON, MSG)
BLOCXX_ASSERTMSG works the same as BLOCXX_ASSERT, but with a second string parameter that will be add...
const char *const LOG_1_LOCATION_opt
@ E_UNKNOWN_LOG_APPENDER_TYPE
static const GlobalString TYPE_STDERR
String of the type of the stderr log appender.
static const GlobalStringArray ALL_CATEGORIES
Pass to createLogAppender to indicate all categories.
#define BLOCXX_GLOBAL_STRING_INIT(str)
void logMessage(const LogMessage &message) const
Log a message using the specified component and category.
bool componentAndCategoryAreEnabled(const String &component, const String &category) const
static const GlobalString STR_ERROR_CATEGORY
static bool setDefaultLogAppender(const LogAppenderRef &ref)
Set the default global LogAppenderRef.
static bool setThreadLogAppender(const LogAppenderRef &ref)
Set a per thread LogAppenderRef that overrides the default one.
LogMessagePatternFormatter m_formatter
bool categoryIsEnabled(const String &category) const
static const GlobalString STR_DEBUG_CATEGORY
Array< String > StringArray
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
static void freeThreadLogAppender(void *ptr)
char const LOG_1_LOCATION_opt[]
char const LOG_1_SYSLOG_FACILITY_opt[]
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.
const char *const LOG_1_SYSLOG_FACILITY_opt
const char *const LOG_1_MAX_BACKUP_INDEX_opt
#define BLOCXX_DEFAULT_LOG_1_SYSLOG_IDENTITY
#define BLOCXX_THROW_ERR(exType, msg, err)
Throw an exception using FILE and LINE.
const char *const LOG_1_SYSLOG_IDENTITY_opt
#define BLOCXX_THROW_ERR_SUBEX(exType, msg, err, subex)
Throw an exception using FILE and LINE.
container_t::const_iterator const_iterator
static const GlobalString TYPE_NULL
String of the type of the null log appender.
const char * c_str() const
#define BLOCXX_DEFAULT_LOG_1_FLUSH
static const GlobalString TYPE_MPFILE
String of the type of the multi-process file log appender.
IntrusiveReference< LogAppender > LogAppenderRef
void BLOCXX_COMMON_API callOnce(OnceFlag &flag, FuncT F)
The first time callOnce is called with a given onceFlag argument, it calls func with no argument and ...
static const GlobalString STR_DEBUG2_CATEGORY
#define BLOCXX_GLOBAL_PTR_INIT
This macro is provided to abstract the details of GlobalPtr.
@ E_INVALID_MAX_FILE_SIZE
const char *const LOG_1_MAX_FILE_SIZE_opt
LazyGlobal< StringArray, const char *const, StringArrayConstructorFactory > GlobalStringArray
SortedVectorSet< String > m_categories
const char *const LOG_1_FLUSH_opt
bool equalsIgnoreCase(const String &arg) const
Determine if another String object is equal to this String object, ignoring case in the comparision.
char const LOG_1_MAX_BACKUP_INDEX_opt[]