|
UniSet
2.2.1
|
00001 // ------------------------------------------------------------------------- 00002 #ifndef LogServer_H_ 00003 #define LogServer_H_ 00004 // ------------------------------------------------------------------------- 00005 #include <list> 00006 #include <string> 00007 #include <memory> 00008 #include <cc++/socket.h> 00009 #include "Mutex.h" 00010 #include "UniXML.h" 00011 #include "DebugStream.h" 00012 #include "ThreadCreator.h" 00013 class LogSession; 00014 class LogAgregator; 00015 class NullLogSession; 00016 // ------------------------------------------------------------------------- 00053 // ------------------------------------------------------------------------- 00054 class LogServer 00055 { 00056 public: 00057 00058 LogServer( std::shared_ptr<DebugStream> log ); 00059 LogServer( std::shared_ptr<LogAgregator> log ); 00060 ~LogServer(); 00061 00062 inline void setSessionTimeout( timeout_t msec ) 00063 { 00064 sessTimeout = msec; 00065 } 00066 inline void setCmdTimeout( timeout_t msec ) 00067 { 00068 cmdTimeout = msec; 00069 } 00070 inline void setOutTimeout( timeout_t msec ) 00071 { 00072 outTimeout = msec; 00073 } 00074 inline void setSessionLog( Debug::type t ) 00075 { 00076 sessLogLevel = t; 00077 } 00078 inline void setMaxSessionCount( int num ) 00079 { 00080 sessMaxCount = num; 00081 } 00082 00083 void run( const std::string& addr, ost::tpport_t port, bool thread = true ); 00084 00085 inline bool isRunning() 00086 { 00087 return (thr && thr->isRunning()); 00088 } 00089 00090 void init( const std::string& prefix, xmlNode* cnode = 0 ); 00091 00092 static std::string help_print( const std::string& prefix ); 00093 00094 protected: 00095 LogServer(); 00096 00097 void work(); 00098 void sessionFinished( std::shared_ptr<LogSession> s ); 00099 00100 private: 00101 typedef std::list< std::shared_ptr<LogSession> > SessionList; 00102 SessionList slist; 00103 UniSetTypes::uniset_rwmutex mutSList; 00104 00105 timeout_t timeout; 00106 timeout_t sessTimeout; 00107 timeout_t cmdTimeout; 00108 timeout_t outTimeout; 00109 Debug::type sessLogLevel; 00110 int sessMaxCount; 00111 00112 std::atomic_bool cancelled; 00113 DebugStream mylog; 00114 std::shared_ptr< ThreadCreator<LogServer> > thr; 00115 00116 std::shared_ptr<ost::TCPSocket> tcp; 00117 std::shared_ptr<DebugStream> elog; 00118 std::shared_ptr<NullLogSession> nullsess; 00119 }; 00120 // ------------------------------------------------------------------------- 00121 #endif // LogServer_H_ 00122 // -------------------------------------------------------------------------
1.7.6.1