2 * @file strict_time_based_rolling_policy.h
3 * @brief log4cxx's rolling policy class. (time)
5 * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6 * Copyright (C) 2008 NTT COMWARE Corporation.
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.
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.
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
23 **********************************************************************/
25 #ifndef __STRICT_TIME_BASED_ROLLING_POLICY_H__
26 #define __STRICT_TIME_BASED_ROLLING_POLICY_H__
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"
37 * log4cxx time based rolling policy class.
38 * this policy class can specify rolling time more strictly
39 * than normal TimeBasedRollingPolicy.
41 class LOG4CXX_EXPORT StrictTimeBasedRollingPolicy :
42 public FixedWindowRollingPolicy,
43 public TriggeringPolicy
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()
53 //! time of next rollover
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
63 LOG_ROTATION_TIMING_TAG rotationTiming;
65 * rotation timing value
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)
75 std::string rotationTimingValue;
76 //! calculate next rollover timing
77 time_t getNextCheck(time_t now_time);
80 //! default constructor
81 StrictTimeBasedRollingPolicy();
82 //! increase reffernce count
84 //! decrease reffernce count
85 void releaseRef() const;
87 void setOption(const LogString&, const LogString&);
88 //! evaluate and activate options
89 void activateOptions(log4cxx::helpers::Pool& );
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&);
100 //! rolling policy initialize
101 RolloverDescriptionPtr initialize(
102 const LogString& file,
104 log4cxx::helpers::Pool& pool);
105 //! invoke when rollover event
106 RolloverDescriptionPtr rollover(const LogString& activeFile,
107 log4cxx::helpers::Pool& pool);
109 //! returns do rollover or not
110 virtual bool isTriggeringEvent(
112 const log4cxx::spi::LoggingEventPtr& event,
113 const LogString& filename,
117 LOG4CXX_PTR_DEF(StrictTimeBasedRollingPolicy);
121 #endif //__STRICT_TIME_BASED_ROLLING_POLICY_H__