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) 2009 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_rotation_enum.h"
39 * log4cxx time based rolling policy class.
40 * this policy class can specify rolling time more strictly
41 * than normal TimeBasedRollingPolicy.
43 class LOG4CXX_EXPORT StrictTimeBasedRollingPolicy :
44 public FixedWindowRollingPolicy,
45 public TriggeringPolicy
47 DECLARE_LOG4CXX_OBJECT(StrictTimeBasedRollingPolicy)
48 BEGIN_LOG4CXX_CAST_MAP()
49 LOG4CXX_CAST_ENTRY(StrictTimeBasedRollingPolicy)
50 LOG4CXX_CAST_ENTRY_CHAIN(FixedWindowRollingPolicy)
51 LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
52 END_LOG4CXX_CAST_MAP()
55 //! time of next rollover
59 * LOG_TIM_YEAR = yearly
60 * LOG_TIM_MONTH = monthly
61 * LOG_TIM_WEEK = weekly
62 * LOG_TIM_DATE = daily
63 * LOG_TIM_HOUR = hourly
65 l7vs::LOG_ROTATION_TIMING_TAG rotationTiming;
67 * rotation timing value
69 * rotation timing value
70 * -------------------------------------------------
71 * LOG_TIM_YEAR "03051500" (3/5 15:00)
72 * LOG_TIM_MONTH "051100" (5 11:00)
73 * LOG_TIM_WEEK "12000" (mon 20:00) sun = 0, sat = 6
74 * LOG_TIM_DATE "1500" (15:00)
75 * LOG_TIM_HOUR "45" (45)
77 std::string rotationTimingValue;
78 //! calculate next rollover timing
79 time_t getNextCheck(time_t now_time);
82 //! default constructor
83 StrictTimeBasedRollingPolicy();
84 //! increase reference count
86 //! decrease reference count
87 void releaseRef() const;
89 void setOption(const LogString &, const LogString &);
90 //! evaluate and activate options
91 void activateOptions(log4cxx::helpers::Pool &);
93 //! rotationTiming getter
94 l7vs::LOG_ROTATION_TIMING_TAG getRotationTiming();
95 //! rotationTiming setter
96 void setRotationTiming(const l7vs::LOG_ROTATION_TIMING_TAG);
97 //! rotationTimingValue getter
98 std::string getRotationTimingValue();
99 //! rotationTimingValue setter
100 void setRotationTimingValue(const std::string &);
102 //! rolling policy initialize
103 RolloverDescriptionPtr initialize(
104 const LogString &file,
106 log4cxx::helpers::Pool &pool);
107 //! invoke when rollover event
108 RolloverDescriptionPtr rollover(const LogString &activeFile,
109 log4cxx::helpers::Pool &pool);
111 //! returns do rollover or not
112 virtual bool isTriggeringEvent(
114 const log4cxx::spi::LoggingEventPtr &event,
115 const LogString &filename,
119 LOG4CXX_PTR_DEF(StrictTimeBasedRollingPolicy);
123 #endif //__STRICT_TIME_BASED_ROLLING_POLICY_H__