00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __PION_XMLLOGSERVICE_HEADER__
00011 #define __PION_XMLLOGSERVICE_HEADER__
00012
00013 #include <boost/thread/mutex.hpp>
00014 #include <boost/scoped_ptr.hpp>
00015 #include <boost/tuple/tuple.hpp>
00016 #include <pion/PionLogger.hpp>
00017 #include <pion/net/WebService.hpp>
00018 #include <pion/net/HTTPResponseWriter.hpp>
00019 #include "PlatformConfig.hpp"
00020 #include "PlatformService.hpp"
00021 #include <string>
00022 #include <list>
00023 #include <deque>
00024 #include <queue>
00025
00026
00027 namespace pion {
00028 namespace plugins {
00029
00030
00034 class XMLLogServiceAppender
00035 : public PionLogAppender
00036 {
00037 public:
00038
00039 XMLLogServiceAppender(void);
00040 virtual ~XMLLogServiceAppender() {}
00041
00043 inline void setMaxEvents(unsigned int n) { m_max_events = n; }
00044
00046 void writeLogEvents(pion::net::HTTPResponseWriterPtr& writer);
00047
00049 void acknowledgeEvent(std::string id);
00050
00052 void acknowledgeAllEvents(void);
00053
00054
00055 private:
00057 static const unsigned int DEFAULT_MAX_EVENTS;
00058
00060 unsigned int m_max_events;
00061
00063 unsigned int m_num_events;
00064
00066 std::list<std::string> m_log_events;
00067
00069 typedef std::map<std::string, std::string> LOG_QUEUE;
00070 LOG_QUEUE m_log_event_queue;
00071
00073 boost::mutex m_log_mutex;
00074
00075 public:
00076
00077 virtual void close() {}
00078 protected:
00079 virtual void append(const log4cplus::spi::InternalLoggingEvent& event);
00080
00081 private:
00083 log4cplus::LogLevelManager m_log_level_manager;
00084 };
00085
00086
00090 class XMLLogService :
00091 public pion::server::PlatformService
00092 {
00093 public:
00094
00095 XMLLogService(void);
00096 virtual ~XMLLogService();
00097
00099 virtual void operator()(pion::net::HTTPRequestPtr& request,
00100 pion::net::TCPConnectionPtr& tcp_conn);
00101
00103 inline XMLLogServiceAppender& getLogAppender(void) {
00104 return dynamic_cast<XMLLogServiceAppender&>(*m_log_appender_ptr);
00105 }
00106
00108 std::string getPermissionType(void) const { return XML_LOG_SERVICE_PERMISSION_TYPE; }
00109
00110 private:
00112 PionLogAppenderPtr m_log_appender_ptr;
00113
00115 static const std::string XML_LOG_SERVICE_PERMISSION_TYPE;
00116 };
00117
00118
00119 }
00120 }
00121
00122 #endif