OSDN Git Service

ticket #416
[ultramonkey-l7/ultramonkey-l7-v3.git] / l7vsd / include / time_and_size_based_rolling_policy.h
1 /*!
2  * @file  time_and_size_based_rolling_policy.h
3  * @brief log4cxx's rolling policy class. (time + size)
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2009  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 __TIME_AND_SIZE_BASED_ROLLING_POLICY_H__
26 #define __TIME_AND_SIZE_BASED_ROLLING_POLICY_H__
27
28 #include <log4cxx/portability.h>
29 #include "strict_time_based_rolling_policy.h"
30 #include "logger_rotation_enum.h"
31
32 namespace log4cxx {
33     namespace rolling {
34         /*!
35          *  log4cxx time and size based rolling policy class.
36          *  this policy class is delivered from StrictTimeBasedRollingPolicy.
37          *  so it can size specify in addition to strict time specify.
38          */
39         class LOG4CXX_EXPORT TimeAndSizeBasedRollingPolicy :
40             public StrictTimeBasedRollingPolicy
41         {
42             DECLARE_LOG4CXX_OBJECT(TimeAndSizeBasedRollingPolicy)
43             BEGIN_LOG4CXX_CAST_MAP()
44                 LOG4CXX_CAST_ENTRY(TimeAndSizeBasedRollingPolicy)
45                 LOG4CXX_CAST_ENTRY_CHAIN(StrictTimeBasedRollingPolicy)
46             END_LOG4CXX_CAST_MAP()
47
48         protected:
49             //! maximum size of file
50             size_t maxFileSize;
51             
52         public:
53             //! default constructor
54             TimeAndSizeBasedRollingPolicy();
55             //! option setter
56             void setOption(const LogString&, const LogString&);
57             //! maxFileSize getter
58             size_t getMaxFileSize();
59             //! maxFileSize setter
60             void setMaxFileSize(size_t);
61             
62             //! returns do rollover or not
63             virtual bool isTriggeringEvent(
64                 Appender* appender,
65                 const log4cxx::spi::LoggingEventPtr& event,
66                 const LogString& filename,
67                 size_t fileLength);
68             
69         };
70         LOG4CXX_PTR_DEF(TimeAndSizeBasedRollingPolicy);
71     }
72 }
73
74 #endif    //__TIME_AND_SIZE_BASED_ROLLING_POLICY_H__
75