OSDN Git Service

アクセスログLogger機能実装クラスのヘッダーファイルを追加
authortsukahara <tsukahara@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Mon, 7 Dec 2009 02:29:07 +0000 (02:29 +0000)
committertsukahara <tsukahara@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Mon, 7 Dec 2009 02:29:07 +0000 (02:29 +0000)
git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-ramiel@8834 1ed66053-1c2d-0410-8867-f7571e6e31d3

l7vsd/include/logger_implement_access.h [new file with mode: 0644]

diff --git a/l7vsd/include/logger_implement_access.h b/l7vsd/include/logger_implement_access.h
new file mode 100644 (file)
index 0000000..1314314
--- /dev/null
@@ -0,0 +1,118 @@
+#ifndef        LOGGER_IMPL_ACCESS_H
+#define        LOGGER_IMPL_ACCESS_H
+
+#include <sstream>
+#include <map>
+#include <log4cxx/logger.h>
+#include <log4cxx/level.h>
+#include <log4cxx/net/syslogappender.h>
+#include <log4cxx/fileappender.h>
+#include <log4cxx/rollingfileappender.h>
+#include <log4cxx/patternlayout.h>
+#include <boost/format.hpp>
+#include <boost/tr1/unordered_map.hpp>
+#include <boost/foreach.hpp>
+#include "appender_property.h"
+
+#define LOGGER_ACCESS_PROCESS_ID "ACCESS"
+
+
+#define LOGGER_NULL "/dev/null"
+
+#define LOGGER_LEVEL_NUM (6)
+
+#define LOG_CAT_L7VSD_ACCESS_LOGGER "l7vsd_access_logger"
+
+namespace log4cxx
+{
+       typedef helpers::ObjectPtrT<RollingFileAppender> RollingFileAppenderPtr;
+}
+
+namespace l7vs{
+
+class logger_implement_access {
+public:
+    
+    typedef std::map< std::string , std::string > accesslog_rotate_map_type;
+
+    logger_implement_access(const std::string &aclogFilename);
+    virtual ~logger_implement_access(){};
+
+       //! initialze function
+       virtual bool init(appender_property& access_log_default_property,const std::map<std::string,std::string>& rotate);
+
+    /*!
+        * output info log.
+        *
+        * @param   category that logging matter occured
+        * @param   log message id
+        * @param   log message
+        * @param   current file
+        * @param   current line
+        * @retrun  void
+        */
+       virtual inline void putLog(const std::string& vsinfo,
+                                                               const std::string& cl_con_org,
+                                                               const std::string& rs_con_org,
+                                                               const std::string& rs_con_dest,
+                                   const std::string& msg){
+/*
+               std::stringstream       buf;
+               buf << boost::format( "%s%d%02d%05d %s %s" )
+                       % LOGGER_ACCESS_PROCESS_ID
+                       % 1
+                       % LOG_CAT_L7VSD_ACCESS_LOGGER
+                       % message_id
+                       % message.c_str()
+                       % hostname;
+                                                                                 
+               try {
+                       log4cxx::Logger::getLogger(LOG_CAT_L7VSD_ACCESS_LOGGER)->forcedLog(     log4cxx::Level::getInfo(),
+                                                                                                                                               buf.str(),
+                                                                                                                                               log4cxx::spi::LocationInfo(file, "", line));
+               }
+               catch (const std::exception& ex) {
+                       std::ostringstream oss;
+                       oss << "Logging Error (Info Log) : " << ex.what();
+                       errorConf( 6, oss.str(), __FILE__, __LINE__);
+               }
+*/
+       }
+
+    void       addRef();
+
+    void       releaseRef();
+
+    bool       operator<=(const int access_num );
+
+    std::string getAcLogFileName(){ return( this->acLogFileName ); }
+
+    bool checkRotateParameterComp(accesslog_rotate_map_type &rotatedata);
+    
+    bool is_rotate_default_flag();
+    
+protected:
+
+    
+    int access_cnt;
+
+    std::string acLogFileName;
+
+       //! initialized flag
+       bool initialized;
+  
+       //! hostname
+    appender_property access_log_property;
+
+    accesslog_rotate_map_type aclog_args;
+    
+    bool rotate_default_flag;
+    
+    bool setAcLoggerConf(appender_property& access_log_default_property,const accesslog_rotate_map_type& rotate);
+
+};
+
+};
+
+#endif //      LOGGER_IMPL_ACCESS_H
+