00001
00014
00016
00017 #ifndef NET_INSTAWEB_APACHE_APACHE_MESSAGE_HANDLER_H_
00018 #define NET_INSTAWEB_APACHE_APACHE_MESSAGE_HANDLER_H_
00019
00020 #include <string>
00021 #include "net/instaweb/apache/apr_timer.h"
00022 #include "net/instaweb/util/public/basictypes.h"
00023 #include "net/instaweb/util/public/google_message_handler.h"
00024 #include "net/instaweb/util/public/message_handler.h"
00025 #include "net/instaweb/util/public/shared_circular_buffer.h"
00026 #include "net/instaweb/util/public/string.h"
00027 #include "net/instaweb/util/public/string_util.h"
00028
00029 struct server_rec;
00030
00031 namespace net_instaweb {
00032
00035 class ApacheMessageHandler : public MessageHandler {
00036 public:
00039 ApacheMessageHandler(const server_rec* server, const StringPiece& version,
00040 Timer* timer);
00044 inline void set_buffer(SharedCircularBuffer* buff) {
00045 buffer_ = buff;
00046 }
00047 void SetPidString(const int64 pid) {
00048 pid_string_ = StrCat("[", Integer64ToString(pid), "]");
00049 }
00051 bool Dump(Writer* writer);
00052
00053 protected:
00054 virtual void MessageVImpl(MessageType type, const char* msg, va_list args);
00055
00056 virtual void FileMessageVImpl(MessageType type, const char* filename,
00057 int line, const char* msg, va_list args);
00058
00059 private:
00060 int GetApacheLogLevel(MessageType type);
00061 GoogleString Format(const char* msg, va_list args);
00062
00063 const server_rec* server_rec_;
00064 const GoogleString version_;
00067 Timer* timer_;
00069 GoogleString pid_string_;
00074 GoogleMessageHandler handler_;
00075 SharedCircularBuffer* buffer_;
00076
00077 DISALLOW_COPY_AND_ASSIGN(ApacheMessageHandler);
00078 };
00079
00080 }
00081
00082 #endif ///< NET_INSTAWEB_APACHE_APACHE_MESSAGE_HANDLER_H_