10 #ifndef __PION_LOGSERVICE_HEADER__
11 #define __PION_LOGSERVICE_HEADER__
13 #include <boost/thread/mutex.hpp>
14 #include <boost/scoped_ptr.hpp>
15 #include <pion/PionLogger.hpp>
16 #include <pion/net/WebService.hpp>
17 #include <pion/net/HTTPResponseWriter.hpp>
21 #if defined(PION_USE_LOG4CXX)
22 #include <log4cxx/appenderskeleton.h>
26 #ifndef _LOG4CXX_HELPERS_POOL_H
44 #ifdef PION_HAS_LOG_APPENDER
45 :
public PionLogAppender
64 static const unsigned int DEFAULT_MAX_EVENTS;
67 unsigned int m_max_events;
70 unsigned int m_num_events;
73 std::list<std::string> m_log_events;
76 boost::mutex m_log_mutex;
78 #if defined(PION_USE_LOG4CXX)
81 virtual void close() {}
82 virtual bool requiresLayout()
const {
return false; }
85 virtual void append(
const log4cxx::spi::LoggingEventPtr& event);
87 virtual void append(
const log4cxx::spi::LoggingEventPtr& event,
88 log4cxx::helpers::Pool& pool)
92 #elif defined(PION_USE_LOG4CPLUS)
95 virtual void close() {}
97 virtual void append(
const log4cplus::spi::InternalLoggingEvent& event);
100 log4cplus::LogLevelManager m_log_level_manager;
101 #elif defined(PION_USE_LOG4CPP)
104 virtual void close() {}
105 virtual bool requiresLayout()
const {
return true; }
106 virtual void setLayout(log4cpp::Layout* layout) { m_layout_ptr.reset(layout); }
109 virtual void _append(
const log4cpp::LoggingEvent& event);
112 boost::scoped_ptr<log4cpp::Layout> m_layout_ptr;
130 virtual void operator()(pion::net::HTTPRequestPtr& request,
131 pion::net::TCPConnectionPtr& tcp_conn);
135 #ifdef PION_HAS_LOG_APPENDER
138 return *m_log_appender_ptr;
144 #ifdef PION_HAS_LOG_APPENDER
145 PionLogAppenderPtr m_log_appender_ptr;
virtual void operator()(pion::net::HTTPRequestPtr &request, pion::net::TCPConnectionPtr &tcp_conn)
handles a new HTTP request
void setMaxEvents(unsigned int n)
sets the maximum number of log events cached in memory
LogServiceAppender & getLogAppender(void)
returns the log appender used by LogService
the following enables use of the lock-free cache
void writeLogEvents(pion::net::HTTPResponseWriterPtr &writer)
writes the events cached in memory to a response stream
void addLogString(const std::string &log_string)
adds a formatted log message to the memory cache