1 | /*
|
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | * contributor license agreements. See the NOTICE file distributed with
|
---|
4 | * this work for additional information regarding copyright ownership.
|
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | * (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | *
|
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 | *
|
---|
11 | * Unless required by applicable law or agreed to in writing, software
|
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | * See the License for the specific language governing permissions and
|
---|
15 | * limitations under the License.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #if !defined(_LOG4CXX_ROLLING_ROLLING_POLICY_H)
|
---|
19 | #define _LOG4CXX_ROLLING_ROLLING_POLICY_H
|
---|
20 |
|
---|
21 | #include <log4cxx/portability.h>
|
---|
22 | #include <log4cxx/spi/optionhandler.h>
|
---|
23 | #include <log4cxx/rolling/rolloverdescription.h>
|
---|
24 | #include <log4cxx/file.h>
|
---|
25 |
|
---|
26 | namespace log4cxx {
|
---|
27 | namespace rolling {
|
---|
28 |
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * A <code>RollingPolicy</code> is responsible for performing the
|
---|
32 | * rolling over of the active log file. The <code>RollingPolicy</code>
|
---|
33 | * is also responsible for providing the <em>active log file</em>,
|
---|
34 | * that is the live file where logging output will be directed.
|
---|
35 | *
|
---|
36 | *
|
---|
37 | *
|
---|
38 | *
|
---|
39 | */
|
---|
40 | class LOG4CXX_EXPORT RollingPolicy :
|
---|
41 | public virtual spi::OptionHandler {
|
---|
42 | DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicy)
|
---|
43 |
|
---|
44 | public:
|
---|
45 | virtual ~RollingPolicy() {}
|
---|
46 | /**
|
---|
47 | * Initialize the policy and return any initial actions for rolling file appender.
|
---|
48 | *
|
---|
49 | * @param file current value of RollingFileAppender.getFile().
|
---|
50 | * @param append current value of RollingFileAppender.getAppend().
|
---|
51 | * @param p pool for memory allocations during call.
|
---|
52 | * @return Description of the initialization, may be null to indicate
|
---|
53 | * no initialization needed.
|
---|
54 | * @throws SecurityException if denied access to log files.
|
---|
55 | */
|
---|
56 | virtual RolloverDescriptionPtr initialize(
|
---|
57 | const LogString& file,
|
---|
58 | const bool append,
|
---|
59 | log4cxx::helpers::Pool& p) = 0;
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Prepare for a rollover. This method is called prior to
|
---|
63 | * closing the active log file, performs any necessary
|
---|
64 | * preliminary actions and describes actions needed
|
---|
65 | * after close of current log file.
|
---|
66 | *
|
---|
67 | * @param activeFile file name for current active log file.
|
---|
68 | * @param p pool for memory allocations during call.
|
---|
69 | * @return Description of pending rollover, may be null to indicate no rollover
|
---|
70 | * at this time.
|
---|
71 | * @throws SecurityException if denied access to log files.
|
---|
72 | */
|
---|
73 | virtual RolloverDescriptionPtr rollover(const LogString& activeFile,
|
---|
74 | log4cxx::helpers::Pool& p) = 0;
|
---|
75 | };
|
---|
76 |
|
---|
77 | LOG4CXX_PTR_DEF(RollingPolicy);
|
---|
78 |
|
---|
79 | }
|
---|
80 | }
|
---|
81 | #endif
|
---|
82 |
|
---|