Coverage Report

Created: 2026-05-30 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/logging-log4cxx/src/main/include/log4cxx/rolling/rollingpolicy.h
Line
Count
Source
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/spi/optionhandler.h>
22
#include <log4cxx/rolling/rolloverdescription.h>
23
#include <log4cxx/file.h>
24
25
namespace LOG4CXX_NS
26
{
27
namespace rolling
28
{
29
30
31
/**
32
 * A <code>RollingPolicy</code> is responsible for performing the
33
 * rolling over of the active log file. The <code>RollingPolicy</code>
34
 * is also responsible for providing the <em>active log file</em>,
35
 * that is the live file where logging output will be directed.
36
 *
37
 *
38
 *
39
 *
40
*/
41
class LOG4CXX_EXPORT RollingPolicy :
42
  public virtual spi::OptionHandler
43
{
44
    DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicy)
45
46
  public:
47
454
    virtual ~RollingPolicy() {}
48
49
    /**
50
     * Initialize the policy and return any initial actions for rolling file appender.
51
     *
52
     * @param currentActiveFile current value of RollingFileAppender.getFile().
53
     * @param append current value of RollingFileAppender.getAppend().
54
     * @return Description of the initialization, may be null to indicate
55
     * no initialization needed.
56
     */
57
#if LOG4CXX_ABI_VERSION <= 15
58
    RolloverDescriptionPtr initialize(const LogString& currentActiveFile, bool append);
59
    /**
60
    @deprecated The \c pool parameter is not used and will be removed in a future version.
61
    Implement this method for now, but plan to migrate to initialize() without a helpers::Pool parameter.
62
    */
63
    virtual RolloverDescriptionPtr initialize(
64
      const   LogString&              currentActiveFile,
65
      const   bool                    append,
66
      LOG4CXX_NS::helpers::Pool& pool) = 0;
67
#define LOG4CXX_ROLLING_POLICY_INITIALIZE_FORMAL_PARAMETERS const LogString& currentActiveFile, bool append, helpers::Pool& p
68
#else
69
    virtual RolloverDescriptionPtr initialize(const LogString& currentActiveFile, bool append) = 0;
70
#define LOG4CXX_ROLLING_POLICY_INITIALIZE_FORMAL_PARAMETERS const LogString& currentActiveFile, bool append
71
    /**
72
    @deprecated The \c pool parameter is not used and will be removed in a future version.
73
    */
74
    [[deprecated("Use initialize() without a Pool parameter instead")]]
75
    RolloverDescriptionPtr initialize(const LogString& currentActiveFile, bool append, helpers::Pool& pool);
76
#endif
77
78
    /**
79
     * Prepare for a rollover.  This method is called prior to
80
     * closing the active log file, performs any necessary
81
     * preliminary actions and describes actions needed
82
     * after close of current log file.
83
     *
84
     * @param currentActiveFile file name for current active log file.
85
     * @param append current value of the parent FileAppender.getAppend().
86
     * @return Description of pending rollover, may be null to indicate no rollover
87
     * at this time.
88
     */
89
#if LOG4CXX_ABI_VERSION <= 15
90
    RolloverDescriptionPtr rollover(const LogString& currentActiveFile, bool append);
91
    /**
92
    @deprecated The \c pool parameter is not used and will be removed in a future version.
93
    Implement this method for now, but plan to migrate to rollover() without a helpers::Pool parameter.
94
    */
95
    virtual RolloverDescriptionPtr rollover(
96
      const   LogString&              currentActiveFile,
97
      const   bool                    append,
98
      LOG4CXX_NS::helpers::Pool& pool) = 0;
99
#define LOG4CXX_ROLLING_POLICY_ROLLOVER_FORMAL_PARAMETERS const LogString& currentActiveFile, bool append, helpers::Pool& p
100
#else
101
    virtual RolloverDescriptionPtr rollover(const LogString& currentActiveFile, bool append) = 0;
102
#define LOG4CXX_ROLLING_POLICY_ROLLOVER_FORMAL_PARAMETERS const LogString& currentActiveFile, bool append
103
    /**
104
    @deprecated The \c pool parameter is not used and will be removed in a future version.
105
    */
106
    [[deprecated("Use rollover() without a Pool parameter instead")]]
107
    RolloverDescriptionPtr rollover(const LogString& currentActiveFile, bool append, helpers::Pool& pool);
108
#endif
109
};
110
111
LOG4CXX_PTR_DEF(RollingPolicy);
112
113
}
114
}
115
#endif
116