OSDN Git Service

ソースツリー再構成中(ほぼOK?)
[ultramonkey-l7/ultramonkey-l7-v3.git] / l7vsd / include / strict_time_based_rolling_policy.h
1 /*!\r
2  * @file  strict_time_based_rolling_policy.h\r
3  * @brief log4cxx's rolling policy class. (time)\r
4  *\r
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing\r
6  * Copyright (C) 2009  NTT COMWARE Corporation.\r
7  *\r
8  * This program is free software; you can redistribute it and/or\r
9  * modify it under the terms of the GNU Lesser General Public\r
10  * License as published by the Free Software Foundation; either\r
11  * version 2.1 of the License, or (at your option) any later version.\r
12  *\r
13  * This program is distributed in the hope that it will be useful,\r
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
16  * Lesser General Public License for more details.\r
17  *      \r
18  * You should have received a copy of the GNU Lesser General Public\r
19  * License along with this library; if not, write to the Free Software\r
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\r
21  * 02110-1301 USA\r
22  *\r
23  **********************************************************************/\r
24 \r
25 #ifndef __STRICT_TIME_BASED_ROLLING_POLICY_H__\r
26 #define __STRICT_TIME_BASED_ROLLING_POLICY_H__\r
27 \r
28 #include <log4cxx/portability.h>\r
29 #include <log4cxx/rolling/rollingpolicybase.h>\r
30 #include <log4cxx/rolling/triggeringpolicy.h>\r
31 #include <log4cxx/rolling/fixedwindowrollingpolicy.h>\r
32 #include "logger_rotation_enum.h"\r
33 \r
34 namespace log4cxx {\r
35         namespace rolling {\r
36                 /*!\r
37                  *  log4cxx time based rolling policy class.\r
38                  *  this policy class can specify rolling time more strictly\r
39                  *  than normal TimeBasedRollingPolicy.\r
40                  */\r
41                 class LOG4CXX_EXPORT StrictTimeBasedRollingPolicy :\r
42                         public FixedWindowRollingPolicy,\r
43                         public TriggeringPolicy\r
44                 {\r
45                         DECLARE_LOG4CXX_OBJECT(StrictTimeBasedRollingPolicy)\r
46                         BEGIN_LOG4CXX_CAST_MAP()\r
47                                 LOG4CXX_CAST_ENTRY(StrictTimeBasedRollingPolicy)\r
48                                 LOG4CXX_CAST_ENTRY_CHAIN(FixedWindowRollingPolicy)\r
49                                 LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)\r
50                         END_LOG4CXX_CAST_MAP()\r
51 \r
52                 protected:\r
53                         //! time of next rollover\r
54                         time_t nextCheck;\r
55                         /*!\r
56                          *  rotation timing\r
57                          *  LOG_TIM_YEAR   = yearly\r
58                          *  LOG_TIM_MONTH  = monthly\r
59                          *  LOG_TIM_WEEK   = weekly\r
60                          *  LOG_TIM_DATE   = daily\r
61                          *  LOG_TIM_HOUR   = hourly\r
62                          */\r
63                         l7vs::LOG_ROTATION_TIMING_TAG rotationTiming;\r
64                         /*!\r
65                          *  rotation timing value \r
66                          *\r
67                          *  rotation timing     value\r
68                          *  -------------------------------------------------\r
69                          *  LOG_TIM_YEAR        "03051500"      (3/5 15:00)\r
70                          *  LOG_TIM_MONTH       "051100"        (5 11:00)\r
71                          *  LOG_TIM_WEEK        "12000"         (mon 20:00) sun = 0, sat = 6\r
72                          *  LOG_TIM_DATE        "1500"          (15:00)\r
73                          *  LOG_TIM_HOUR        "45"            (45)\r
74                          */\r
75                         std::string rotationTimingValue;\r
76                         //! calculate next rollover timing\r
77                         time_t getNextCheck(time_t now_time);\r
78                         \r
79                 public:\r
80                         //! default constructor\r
81                         StrictTimeBasedRollingPolicy();\r
82                         //! increase reffernce count\r
83                         void addRef() const;\r
84                         //! decrease reffernce count\r
85                         void releaseRef() const;\r
86                         //! option setter\r
87                         void setOption(const LogString&, const LogString&);\r
88                         //! evaluate and activate options\r
89                         void activateOptions(log4cxx::helpers::Pool& );\r
90 \r
91                         //! rotationTiming getter\r
92                         l7vs::LOG_ROTATION_TIMING_TAG getRotationTiming();\r
93                         //! rotationTiming setter\r
94                         void setRotationTiming(const l7vs::LOG_ROTATION_TIMING_TAG);\r
95                         //! rotatioTimingValue getter\r
96                         std::string getRotationTimingValue();\r
97                         //! rotatioTimingValue setter\r
98                         void setRotationTimingValue(const std::string&);\r
99                         \r
100                         //! rolling policy initialize\r
101                         RolloverDescriptionPtr initialize(\r
102                                 const LogString& file,\r
103                                 const bool append,\r
104                                 log4cxx::helpers::Pool& pool);\r
105                         //! invoke when rollover event\r
106                         RolloverDescriptionPtr rollover(const LogString& activeFile,\r
107                                 log4cxx::helpers::Pool& pool);\r
108                         \r
109                         //! returns do rollover or not \r
110                         virtual bool isTriggeringEvent(\r
111                                 Appender* appender,\r
112                                 const log4cxx::spi::LoggingEventPtr& event,\r
113                                 const LogString& filename,\r
114                                 size_t fileLength);\r
115                         \r
116                 };\r
117                 LOG4CXX_PTR_DEF(StrictTimeBasedRollingPolicy);\r
118         }\r
119 }\r
120 \r
121 #endif  //__STRICT_TIME_BASED_ROLLING_POLICY_H__\r
122 \r