OSDN Git Service

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