• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

loggingACSRemoteAppender.h

Go to the documentation of this file.
00001 #ifndef LOGGING_ACSREMOTEAPPENDER_H_
00002 #define LOGGING_ACSREMOTEAPPENDER_H_
00003 
00004 /*******************************************************************************
00005 * ALMA - Atacama Large Millimiter Array
00006 * (c) UNSPECIFIED - FILL IN, 2005
00007 *
00008 * This library is free software; you can redistribute it and/or
00009 * modify it under the terms of the GNU Lesser General Public
00010 * License as published by the Free Software Foundation; either
00011 * version 2.1 of the License, or (at your option) any later version.
00012 *
00013 * This library is distributed in the hope that it will be useful,
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 * Lesser General Public License for more details.
00017 *
00018 * You should have received a copy of the GNU Lesser General Public
00019 * License along with this library; if not, write to the Free Software
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00021 *
00022 * "@(#) $Id: loggingACSRemoteAppender.h,v 1.6 2011/07/25 20:56:33 javarias Exp $"
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         //worker entry thread function, it flush the thread at regular intervals or
00084         //when the cache reaches the max size
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

Generated on Thu Jan 12 2012 23:13:51 for ACS-10.0 C++ API by  doxygen 1.7.0