00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00037 #ifndef BLOCXX_LOG_APPENDER_IFC_HPP_INCLUDE_GUARD_
00038 #define BLOCXX_LOG_APPENDER_IFC_HPP_INCLUDE_GUARD_
00039 #include "blocxx/BLOCXX_config.h"
00040 #include "blocxx/CommonFwd.hpp"
00041 #include "blocxx/IntrusiveCountableBase.hpp"
00042 #include "blocxx/SortedVectorSet.hpp"
00043 #include "blocxx/LogConfig.hpp"
00044 #include "blocxx/LogMessagePatternFormatter.hpp"
00045
00046
00047
00048 #ifndef BLOCXX_DEFAULT_LOG_1_MAX_FILE_SIZE
00049 #define BLOCXX_DEFAULT_LOG_1_MAX_FILE_SIZE "0"
00050 #endif
00051 #ifndef BLOCXX_DEFAULT_LOG_1_MAX_BACKUP_INDEX
00052 #define BLOCXX_DEFAULT_LOG_1_MAX_BACKUP_INDEX "1"
00053 #endif
00054 #ifndef BLOCXX_DEFAULT_LOG_1_FLUSH
00055 #define BLOCXX_DEFAULT_LOG_1_FLUSH "true"
00056 #endif
00057 #ifndef BLOCXX_DEFAULT_LOG_1_SYSLOG_IDENTITY
00058 #define BLOCXX_DEFAULT_LOG_1_SYSLOG_IDENTITY BLOCXX_PACKAGE_PREFIX"blocxx"
00059 #endif
00060 #ifndef BLOCXX_DEFAULT_LOG_1_SYSLOG_FACILITY
00061 #define BLOCXX_DEFAULT_LOG_1_SYSLOG_FACILITY "user"
00062 #endif
00063
00064 namespace BLOCXX_NAMESPACE
00065 {
00066
00067 #ifdef BLOCXX_WIN32
00068 template class BLOCXX_COMMON_API Array<String>;
00069 template class BLOCXX_COMMON_API SortedVectorSet<String>;
00070 #endif
00071
00072 class BLOCXX_COMMON_API LogAppender : public IntrusiveCountableBase
00073 {
00074 public:
00075
00076
00077 static const char* const LOG_1_LOCATION_opt;
00078 static const char* const LOG_1_MAX_FILE_SIZE_opt;
00079 static const char* const LOG_1_MAX_BACKUP_INDEX_opt;
00080 static const char* const LOG_1_FLUSH_opt;
00081 static const char* const LOG_1_SYSLOG_IDENTITY_opt;
00082 static const char* const LOG_1_SYSLOG_FACILITY_opt;
00083
00084 virtual ~LogAppender();
00085
00090 void logMessage(const LogMessage& message) const;
00091
00092 bool categoryIsEnabled(const String& category) const;
00093 bool componentAndCategoryAreEnabled(const String& component, const String& category) const;
00094
00095 ELogLevel getLogLevel() const;
00096
00121 static LogAppenderRef createLogAppender(
00122 const String& name,
00123 const StringArray& components,
00124 const StringArray& categories,
00125 const String& messageFormat,
00126 const String& type,
00127 const LoggerConfigMap& configItems);
00128
00130 static const StringArray ALL_COMPONENTS;
00132 static const StringArray ALL_CATEGORIES;
00135 static const String STR_TTCC_MESSAGE_FORMAT;
00137 static const String TYPE_SYSLOG;
00139 static const String TYPE_STDERR;
00141 static const String TYPE_FILE;
00143 static const String TYPE_NULL;
00144
00145 protected:
00146
00147 LogAppender(const StringArray& components, const StringArray& categories, const String& pattern);
00148
00149 private:
00150 virtual void doProcessLogMessage(const String& formattedMessage, const LogMessage& message) const = 0;
00151
00152 private:
00153 SortedVectorSet<String> m_components;
00154 bool m_allComponents;
00155 SortedVectorSet<String> m_categories;
00156 bool m_allCategories;
00157
00158 LogMessagePatternFormatter m_formatter;
00159
00160 };
00161 BLOCXX_EXPORT_TEMPLATE(BLOCXX_COMMON_API, IntrusiveReference, LogAppender);
00162
00163 }
00164
00165 #endif
00166
00167