Apache log4cxx  Version 0.12.1
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 
78  public:
80  virtual ~RollingPolicyBase();
81  virtual void activateOptions(log4cxx::helpers::Pool& p) = 0;
82  virtual log4cxx::pattern::PatternMap getFormatSpecifiers() const = 0;
83 
84  virtual void setOption(const LogString& option,
85  const LogString& value);
86 
91  void setFileNamePattern(const LogString& fnp);
92 
97  LogString getFileNamePattern() const;
98 
99 
100 #ifdef LOG4CXX_MULTI_PROCESS
101  PatternConverterList getPatternConverterList()
102  {
103  return patternConverters;
104  }
105 #endif
106  protected:
110  void parseFileNamePattern();
111 
119  void formatFileName(log4cxx::helpers::ObjectPtr& obj,
120  LogString& buf, log4cxx::helpers::Pool& p) const;
121 
122  log4cxx::pattern::PatternConverterPtr getIntegerPatternConverter() const;
123  log4cxx::pattern::PatternConverterPtr getDatePatternConverter() const;
124 
125 
126 };
127 }
128 }
129 
130 
131 #if defined(_MSC_VER)
132  #pragma warning ( pop )
133 #endif
134 
135 #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:148
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
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)