Apache log4cxx  Version 0.13.0
rollingpolicybase.h
Go to the documentation of this file.
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>
34 
35 namespace log4cxx
36 {
37 namespace rolling
38 {
39 LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
41 
49 class LOG4CXX_EXPORT RollingPolicyBase :
50  public virtual RollingPolicy,
51  public virtual helpers::Object
52 {
53  protected:
59 
60 
61  private:
65  PatternConverterList patternConverters;
66 
70  FormattingInfoList patternFields;
71 
75  LogString fileNamePatternStr;
76 
77  bool createIntermediateDirectories;
78 
79 
80  public:
82  virtual ~RollingPolicyBase();
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  bool getCreateIntermediateDirectories() const;
102  void setCreateIntermediateDirectories(bool createIntermediate);
103 
104 
105 #ifdef LOG4CXX_MULTI_PROCESS
106  PatternConverterList getPatternConverterList()
107  {
108  return patternConverters;
109  }
110 #endif
111  protected:
115  void parseFileNamePattern();
116 
124  void formatFileName(log4cxx::helpers::ObjectPtr& obj,
125  LogString& buf, log4cxx::helpers::Pool& p) const;
126 
127  log4cxx::pattern::PatternConverterPtr getIntegerPatternConverter() const;
128  log4cxx::pattern::PatternConverterPtr getDatePatternConverter() const;
129 
130 
131 };
132 }
133 }
134 
135 
136 #if defined(_MSC_VER)
137  #pragma warning ( pop )
138 #endif
139 
140 #endif
std::shared_ptr< FormattingInfo > FormattingInfoPtr
Definition: formattinginfo.h:31
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:26
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:153
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:147
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:141
base class for java-like objects.
Definition: object.h:101
A RollingPolicy is responsible for performing the rolling over of the active log file.
Definition: rollingpolicy.h:42
std::shared_ptr< Object > ObjectPtr
Definition: propertysetter.h:28
Definition: pool.h:32
A string based interface to configure package components.
Definition: optionhandler.h:34
std::map< LogString, PatternConstructor > PatternMap
Definition: patternparser.h:41
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66
Implements methods common to most, it not all, rolling policies.
Definition: rollingpolicybase.h:49
LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr)