00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _LOG4CXX_UCM_APPENDER_H
00018 #define _LOG4CXX_UCM_APPENDER_H
00019 #ifdef _UCMLOGGER_
00020 #include "StLoggerConfig.h"
00021
00022 #include <log4cxx/helpers/exception.h>
00023 #include <log4cxx/appenderskeleton.h>
00024 #include <log4cxx/spi/loggingevent.h>
00025 #include <list>
00026
00027 namespace TxLogging {
00028 class TxEventLog;
00029 }
00030
00031 namespace log4cxx
00032 {
00033 namespace db
00034 {
00035 #if REDUNDANT_EXCEPTION
00036 class LOG4CXX_EXPORT UCMException : public helpers::Exception
00037 {
00038 public:
00039 UCMException(int code) : code(code) {}
00040 virtual String getMessage() { return String(); }
00041 ~UCMException() {}
00042 int code;
00043 };
00044 #endif
00045
00046 class StUCMAppender;
00047 #if (STAR_LOG4CXX_VERSION != 10)
00048 typedef helpers::ObjectPtrT<StUCMAppender> StUCMAppenderPtr;
00049 #endif
00050
00096 class LOG4CXX_EXPORT StUCMAppender : public AppenderSkeleton
00097 {
00098 protected:
00102 String databaseURL;
00103
00107 String databaseUser;
00108
00112 String databasePassword;
00113
00121 TxLogging::TxEventLog *connection;
00122
00126 String technology;
00127
00142 size_t bufferSize;
00143
00147 std::list<spi::LoggingEventPtr> buffer;
00148 unsigned long fLastId;
00149 bool fIsConnectionOpen;
00150 #if (STAR_LOG4CXX_VERSION == 10)
00151 protected:
00152 virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
00153 #endif
00154
00155 public:
00156 DECLARE_LOG4CXX_OBJECT(StUCMAppender)
00157 BEGIN_LOG4CXX_CAST_MAP()
00158 LOG4CXX_CAST_ENTRY(StUCMAppender)
00159 LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
00160 END_LOG4CXX_CAST_MAP()
00161
00162 StUCMAppender(const char *mode="F");
00163 virtual ~StUCMAppender();
00164
00168 virtual void setOption(const String& option, const String& value);
00169
00173 void append(const spi::LoggingEventPtr& event);
00174
00183 protected:
00184 String getLogStatement(const spi::LoggingEventPtr& event);
00185
00186
00194 virtual void closeConnection();
00195
00202 virtual TxLogging::TxEventLog *getConnection() ;
00203
00208 public:
00209 virtual void close();
00210
00211
00212
00213
00214
00215
00216
00217 void flushBuffer();
00218
00237
00238 virtual bool requiresLayout() const
00239 { return true; }
00240
00241 inline void setUser(const String& user)
00242 { databaseUser = user; }
00243
00244
00245 inline void setURL(const String& url)
00246 { databaseURL = url; }
00247
00248
00249 inline void setPassword(const String& password)
00250 { databasePassword = password; }
00251
00252
00253 inline void setBufferSize(size_t newBufferSize)
00254 { bufferSize = newBufferSize; }
00255
00256 inline const String& getUser() const
00257 { return databaseUser; }
00258
00259
00260 inline const String& getURL() const
00261 { return databaseURL; }
00262
00263
00264 inline const String& getPassword() const
00265 { return databasePassword; }
00266
00267 inline size_t getBufferSize() const
00268 { return bufferSize; }
00269 };
00270 #if (STAR_LOG4CXX_VERSION == 10)
00271 LOG4CXX_PTR_DEF(StUCMAppender);
00272 #endif
00273 }
00274 };
00275 #endif
00276 #endif // _LOG4CXX_UCM_APPENDER_H