2 * @file strict_time_based_rolling_policy.h
\r
3 * @brief log4cxx's rolling policy class. (time)
\r
5 * L7VSD: Linux Virtual Server for Layer7 Load Balancing
\r
6 * Copyright (C) 2009 NTT COMWARE Corporation.
\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
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
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
23 **********************************************************************/
\r
25 #ifndef __STRICT_TIME_BASED_ROLLING_POLICY_H__
\r
26 #define __STRICT_TIME_BASED_ROLLING_POLICY_H__
\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
37 * log4cxx time based rolling policy class.
\r
38 * this policy class can specify rolling time more strictly
\r
39 * than normal TimeBasedRollingPolicy.
\r
41 class LOG4CXX_EXPORT StrictTimeBasedRollingPolicy :
\r
42 public FixedWindowRollingPolicy,
\r
43 public TriggeringPolicy
\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
53 //! time of next rollover
\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
63 l7vs::LOG_ROTATION_TIMING_TAG rotationTiming;
\r
65 * rotation timing value
\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
75 std::string rotationTimingValue;
\r
76 //! calculate next rollover timing
\r
77 time_t getNextCheck(time_t now_time);
\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
87 void setOption(const LogString&, const LogString&);
\r
88 //! evaluate and activate options
\r
89 void activateOptions(log4cxx::helpers::Pool& );
\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
100 //! rolling policy initialize
\r
101 RolloverDescriptionPtr initialize(
\r
102 const LogString& file,
\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
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
117 LOG4CXX_PTR_DEF(StrictTimeBasedRollingPolicy);
\r
121 #endif //__STRICT_TIME_BASED_ROLLING_POLICY_H__
\r