39 #include "blocxx/BLOCXX_config.h" 89 delete static_cast<LogAppenderRef *>(ptr);
97 OnceFlag g_onceGuard = BLOCXX_ONCE_INIT;
98 NonRecursiveMutex* g_mutexGuard = NULL;
100 struct NullAppenderFactory
111 void initGuardAndKey()
113 g_mutexGuard =
new NonRecursiveMutex();
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);
187 ptr = static_cast<LogAppenderRef *>(TlsGetValue(dwTlsIndex));
189 pthread_addr_t addr_ptr = NULL;
190 int ret = pthread_getspecific(g_loggerKey, &addr_ptr);
193 ptr = static_cast<LogAppenderRef *>(addr_ptr);
196 ptr = static_cast<LogAppenderRef *>(pthread_getspecific(g_loggerKey));
214 callOnce(g_onceGuard, initGuardAndKey);
221 LogAppenderRef *ptr_old = static_cast<LogAppenderRef *>(TlsGetValue(dwTlsIndex));
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
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!");
char const LOG_1_MAX_FILE_SIZE_opt[]
char const LOG_1_SYSLOG_IDENTITY_opt[]
static const GlobalStringArray ALL_CATEGORIES
Pass to createLogAppender to indicate all categories.
LogMessagePatternFormatter m_formatter
bool equalsIgnoreCase(const String &arg) const
Determine if another String object is equal to this String object, ignoring case in the comparision.
const_iterator end() const
#define BLOCXX_DEFAULT_LOG_1_SYSLOG_IDENTITY
bool categoryIsEnabled(const String &category) const
#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_FLUSH_opt
SortedVectorSet< String > m_components
char const LOG_1_MAX_BACKUP_INDEX_opt[]
char const LOG_1_LOCATION_opt[]
IntrusiveReference< LogAppender > LogAppenderRef
const char *const LOG_1_MAX_FILE_SIZE_opt
static const GlobalString STR_DEBUG2_CATEGORY
#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.
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.
This String class is an abstract data type that represents as NULL terminated string of characters.
static const GlobalString STR_INFO_CATEGORY
void logMessage(const LogMessage &message) const
Log a message using the specified component and category.
static const GlobalString STR_DEBUG3_CATEGORY
static const GlobalString TYPE_MPFILE
String of the type of the multi-process file log appender.
const char * c_str() const
static const GlobalString STR_FATAL_CATEGORY
static LogAppenderRef getThreadLogAppender()
Returns a copy of the thread LogAppenderRef.
#define BLOCXX_THROW_ERR_SUBEX(exType, msg, err, subex)
Throw an exception using FILE and LINE.
static const GlobalString TYPE_STDERR
String of the type of the stderr log appender.
const char *const LOG_1_MAX_BACKUP_INDEX_opt
static const GlobalString STR_TTCC_MESSAGE_FORMAT
The Log4j TTCC message format - TTCC is acronym for Time Thread Category Component.
This class sends log messges to a file, for use when there may be multiple processes logging to the s...
virtual const char * getMessage() const
Returns the message.
static LogAppenderRef getDefaultLogAppender()
Returns a copy of default LogAppenderRef.
static const GlobalString TYPE_NULL
String of the type of the null log appender.
SortedVectorSet< String > m_categories
#define BLOCXX_DEFAULT_LOG_1_MAX_FILE_SIZE
#define BLOCXX_DEFAULT_LOG_1_FLUSH
#define BLOCXX_GLOBAL_STRING_INIT(str)
static const GlobalStringArray ALL_COMPONENTS
Pass to createLogAppender to indicate all components.
#define BLOCXX_DEFAULT_LOG_1_SYSLOG_FACILITY
container_t::const_iterator const_iterator
This class sends log messges to a file.
static const GlobalString STR_WARNING_CATEGORY
#define BLOCXX_DEFAULT_LOG_1_MAX_BACKUP_INDEX
static void freeThreadLogAppender(void *ptr)
virtual void doProcessLogMessage(const String &formattedMessage, const LogMessage &message) const =0
const 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 ...
static const GlobalString STR_DEBUG_CATEGORY
static LogAppenderRef getCurrentLogAppender()
Get a copy of the per thread LogAppenderRef or if not set, the default one.
bool componentAndCategoryAreEnabled(const String &component, const String &category) const
This class can be used to store a global variable that is lazily initialized in a thread safe manner.
const_iterator find(const key_type &x) const
static const GlobalString STR_ERROR_CATEGORY
static const GlobalString TYPE_SYSLOG
String of the type of the syslog log appender.
char const LOG_1_SYSLOG_FACILITY_opt[]
const char *const LOG_1_SYSLOG_IDENTITY_opt
Note that descriptions of what exceptions may be thrown assumes that object is used correctly,...
void swap(IntrusiveReference &rhs)
char const LOG_1_FLUSH_opt[]
This class sends log messges to syslog.
The CerrAppender is a LogAppender derivative that sends log message to stderr.
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 const GlobalString TYPE_FILE
String of the type of the file log appender.
This class sends log messges to the bit bucket.
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.
const char *const LOG_1_SYSLOG_FACILITY_opt