Go to the documentation of this file.00001 #ifndef LOGGING_ACSREMOTEAPPENDER_H_
00002 #define LOGGING_ACSREMOTEAPPENDER_H_
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 #define LOG4CPP_FIX_ERROR_COLLISION 1
00028 #include <log4cpp/LayoutAppender.hh>
00029 
00030 #include <iostream>
00031 #include <deque>
00032 #include <pthread.h>
00033 
00034 #include <ace/Synch.h>
00035 
00036 #include "loggingLogThrottle.h"
00037 #include "logging_idlC.h"
00038 
00039 namespace logging {
00040 
00041 class ACSRemoteAppender: public virtual log4cpp::LayoutAppender{
00042 public:
00043         ACSRemoteAppender(const std::string& name,
00044                         unsigned long cacheSize,
00045                         unsigned int autoFlushTimeoutSec,
00046                         Logging::AcsLogService_ptr centralizedLogger,
00047                         int maxLogsPerSecond);
00048         virtual ~ACSRemoteAppender();
00049         void close();
00050 
00051 protected:
00052         void _append(const log4cpp::LoggingEvent& event);
00053 
00054 private:
00055         log4cpp::Priority::Value _threshold;
00056         log4cpp::Filter* _filter;
00057 
00058 };
00059 
00063 class RemoteLoggerBuffer {
00064 public :
00065         RemoteLoggerBuffer(unsigned long cacheSize,
00066                         unsigned int autoFlushTimeoutSec,
00067                         Logging::AcsLogService_ptr centralizedLogger,
00068                         int maxLogsPerSecond );
00069         void append(Logging::XmlLogRecord& log);
00070         ~RemoteLoggerBuffer();
00071 private:
00072         void sendLog(Logging::XmlLogRecord& log);
00073         void sendLog(Logging::XmlLogRecordSeq& logs);
00074         void flushCache();
00075 
00076         unsigned int _cacheSize;
00077         unsigned int _flushTimeout;
00078         Logging::AcsLogService_ptr _logger;
00079         std::deque<Logging::XmlLogRecord>* _cache;
00080         ACE_Thread_Mutex _cacheMutex;
00081         logging::LogThrottle* _logThrottle;
00082         pthread_t thread;
00083         
00084         
00085         static void* worker(void* arg);
00086         void svc();
00087         ACE_SYNCH_MUTEX _workCondThreadMutex;
00088         ACE_SYNCH_CONDITION _workCond;
00089         bool _stopThread;
00090 
00091 };
00092 }
00093 
00094 #endif