39#include "blocxx/BLOCXX_config.h"
97OnceFlag g_onceGuard = BLOCXX_ONCE_INIT;
100struct NullAppenderFactory
107::BLOCXX_NAMESPACE::GlobalPtr<LogAppenderRef,NullAppenderFactory> g_defaultLogAppender =
BLOCXX_GLOBAL_PTR_INIT;
111void initGuardAndKey()
115 LPVOID thread_data = NULL;
116 BOOL ret = TlsSetValue(dwTlsIndex, thread_data)
136 if(threadLogAppender)
138 return threadLogAppender;
151 callOnce(g_onceGuard, initGuardAndKey);
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);
291 if (i != configItems.
end())
308 const String& messageFormat,
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);
368 ).equalsIgnoreCase(
"true");
370 components, categories, filename.
c_str(), messageFormat,
371 maxFileSize, maxBackupIndex, flushLog
377 components, categories, filename, messageFormat,
378 maxFileSize, maxBackupIndex
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!");
#define BLOCXX_ASSERTMSG(CON, MSG)
BLOCXX_ASSERTMSG works the same as BLOCXX_ASSERT, but with a second string parameter that will be add...
#define BLOCXX_THROW_ERR_SUBEX(exType, msg, err, subex)
Throw an exception using FILE and LINE.
#define BLOCXX_THROW_ERR(exType, msg, err)
Throw an exception using FILE and LINE.
#define BLOCXX_GLOBAL_PTR_INIT
This macro is provided to abstract the details of GlobalPtr.
#define BLOCXX_GLOBAL_STRING_INIT(str)
#define BLOCXX_DEFAULT_LOG_1_SYSLOG_IDENTITY
#define BLOCXX_DEFAULT_LOG_1_FLUSH
#define BLOCXX_DEFAULT_LOG_1_MAX_FILE_SIZE
#define BLOCXX_DEFAULT_LOG_1_MAX_BACKUP_INDEX
#define BLOCXX_DEFAULT_LOG_1_SYSLOG_FACILITY
The CerrAppender is a LogAppender derivative that sends log message to stderr.
virtual const char * getMessage() const
Returns the message.
This class sends log messges to a file.
void swap(IntrusiveReference &rhs)
static const GlobalStringArray ALL_CATEGORIES
Pass to createLogAppender to indicate all categories.
static LogAppenderRef getDefaultLogAppender()
Returns a copy of default LogAppenderRef.
static const GlobalString TYPE_MPFILE
String of the type of the multi-process file log appender.
static const GlobalString TYPE_FILE
String of the type of the file log appender.
bool componentAndCategoryAreEnabled(const String &component, const String &category) const
LogAppender(const StringArray &components=ALL_COMPONENTS, const StringArray &categories=ALL_CATEGORIES, const String &pattern=STR_TTCC_MESSAGE_FORMAT)
static const GlobalString TYPE_SYSLOG
String of the type of the syslog log appender.
static bool setDefaultLogAppender(const LogAppenderRef &ref)
Set the default global LogAppenderRef.
SortedVectorSet< String > m_categories
SortedVectorSet< String > m_components
static LogAppenderRef getThreadLogAppender()
Returns a copy of the thread LogAppenderRef.
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.
bool categoryIsEnabled(const String &category) const
static const GlobalStringArray ALL_COMPONENTS
Pass to createLogAppender to indicate all components.
static LogAppenderRef getCurrentLogAppender()
Get a copy of the per thread LogAppenderRef or if not set, the default one.
virtual void doProcessLogMessage(const String &formattedMessage, const LogMessage &message) const =0
static const GlobalString STR_TTCC_MESSAGE_FORMAT
The Log4j TTCC message format - TTCC is acronym for Time Thread Category Component.
static const GlobalString TYPE_NULL
String of the type of the null log appender.
void logMessage(const LogMessage &message) const
Log a message using the specified component and category.
static const GlobalString TYPE_STDERR
String of the type of the stderr log appender.
LogMessagePatternFormatter m_formatter
static bool setThreadLogAppender(const LogAppenderRef &ref)
Set a per thread LogAppenderRef that overrides the default one.
static const GlobalString STR_DEBUG2_CATEGORY
static const GlobalString STR_WARNING_CATEGORY
static const GlobalString STR_DEBUG3_CATEGORY
static const GlobalString STR_DEBUG_CATEGORY
static const GlobalString STR_FATAL_CATEGORY
static const GlobalString STR_ERROR_CATEGORY
@ E_UNKNOWN_LOG_APPENDER_TYPE
@ E_INVALID_MAX_BACKUP_INDEX
@ E_INVALID_MAX_FILE_SIZE
static const GlobalString STR_INFO_CATEGORY
This class sends log messges to a file, for use when there may be multiple processes logging to the s...
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
This class sends log messges to the bit bucket.
const_iterator end() const
const_iterator find(const key_type &x) const
container_t::const_iterator const_iterator
This String class is an abstract data type that represents as NULL terminated string of characters.
bool equalsIgnoreCase(const String &arg) const
Determine if another String object is equal to this String object, ignoring case in the comparision.
const char * c_str() const
This class sends log messges to syslog.
const char *const LOG_1_FLUSH_opt
const char *const LOG_1_SYSLOG_FACILITY_opt
const char *const LOG_1_SYSLOG_IDENTITY_opt
const char *const LOG_1_MAX_FILE_SIZE_opt
const char *const LOG_1_LOCATION_opt
const char *const LOG_1_MAX_BACKUP_INDEX_opt
LazyGlobal< StringArray, const char *const, StringArrayConstructorFactory > GlobalStringArray
char const LOG_1_LOCATION_opt[]
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 ...
LazyGlobal< String, char const *const > GlobalString
char const LOG_1_MAX_FILE_SIZE_opt[]
char const LOG_1_SYSLOG_FACILITY_opt[]
char const LOG_1_FLUSH_opt[]
Array< String > StringArray
static void freeThreadLogAppender(void *ptr)
char const LOG_1_MAX_BACKUP_INDEX_opt[]
IntrusiveReference< LogAppender > LogAppenderRef
SortedVectorMap< String, String > LoggerConfigMap
char const LOG_1_SYSLOG_IDENTITY_opt[]