Apache log4cxx  Version 0.11.0
rollingpolicybase.h
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_BASE_H)
19 #define _LOG4CXX_ROLLING_ROLLING_POLICY_BASE_H
20 
21 #if defined(_MSC_VER)
22  #pragma warning ( push )
23  #pragma warning ( disable: 4231 4251 4275 4786 )
24 #endif
25 
26 
27 #include <log4cxx/helpers/object.h>
28 #include <log4cxx/logger.h>
29 #include <log4cxx/logmanager.h>
30 #include <log4cxx/rolling/rollingpolicy.h>
31 #include <log4cxx/pattern/patternconverter.h>
32 #include <log4cxx/pattern/formattinginfo.h>
33 #include <log4cxx/pattern/patternparser.h>
34 
35 namespace log4cxx
36 {
37 namespace rolling
38 {
39 LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
40 LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
41 
49 class LOG4CXX_EXPORT RollingPolicyBase :
50  public virtual RollingPolicy,
51  public virtual helpers::ObjectImpl
52 {
53  protected:
54  DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicyBase)
55  BEGIN_LOG4CXX_CAST_MAP()
56  LOG4CXX_CAST_ENTRY(RollingPolicy)
57  LOG4CXX_CAST_ENTRY(spi::OptionHandler)
58  END_LOG4CXX_CAST_MAP()
59 
60 
61  private:
65  PatternConverterList patternConverters;
66 
70  FormattingInfoList patternFields;
71 
75  LogString fileNamePatternStr;
76 
77 
78  public:
80  virtual ~RollingPolicyBase();
81  void addRef() const;
82  void releaseRef() const;
83  virtual void activateOptions(log4cxx::helpers::Pool& p) = 0;
84  virtual log4cxx::pattern::PatternMap getFormatSpecifiers() const = 0;
85 
86  virtual void setOption(const LogString& option,
87  const LogString& value);
88 
93  void setFileNamePattern(const LogString& fnp);
94 
99  LogString getFileNamePattern() const;
100 
101 
102 #ifdef LOG4CXX_MULTI_PROCESS
103  PatternConverterList getPatternConverterList()
104  {
105  return patternConverters;
106  }
107 #endif
108  protected:
112  void parseFileNamePattern();
113 
121  void formatFileName(log4cxx::helpers::ObjectPtr& obj,
122  LogString& buf, log4cxx::helpers::Pool& p) const;
123 
124  log4cxx::pattern::PatternConverterPtr getIntegerPatternConverter() const;
125  log4cxx::pattern::PatternConverterPtr getDatePatternConverter() const;
126 
127 
128 };
129 }
130 }
131 
132 
133 #if defined(_MSC_VER)
134  #pragma warning ( pop )
135 #endif
136 
137 #endif
Implementation class for Object.
Definition: objectimpl.h:28
A RollingPolicy is responsible for performing the rolling over of the active log file.
Definition: rollingpolicy.h:42
Definition: pool.h:32
A string based interface to configure package components.
Definition: optionhandler.h:35
Definition: appender.h:33
Implements methods common to most, it not all, rolling policies.
Definition: rollingpolicybase.h:49
smart pointer to a Object descendant
Definition: objectptr.h:54