Apache log4cxx  Version 0.11.0
rollingfileappenderskeleton.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_FILE_APPENDER_SKELETON_H)
19 #define _LOG4CXX_ROLLING_ROLLING_FILE_APPENDER_SKELETON_H
20 
21 #include <log4cxx/portability.h>
22 #include <log4cxx/spi/optionhandler.h>
23 #include <log4cxx/fileappender.h>
24 #include <log4cxx/rolling/triggeringpolicy.h>
25 #include <log4cxx/rolling/rollingpolicy.h>
26 #include <log4cxx/rolling/action.h>
27 
28 namespace log4cxx
29 {
30 namespace rolling
31 {
32 
33 
40 class LOG4CXX_EXPORT RollingFileAppenderSkeleton : public FileAppender
41 {
42  DECLARE_LOG4CXX_OBJECT(RollingFileAppenderSkeleton)
43  BEGIN_LOG4CXX_CAST_MAP()
44  LOG4CXX_CAST_ENTRY(RollingFileAppenderSkeleton)
45  LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
46  END_LOG4CXX_CAST_MAP()
47 
48 
51  TriggeringPolicyPtr triggeringPolicy;
52 
56  RollingPolicyPtr rollingPolicy;
57 
61  size_t fileLength;
62 
66  spi::LoggingEventPtr* _event;
67  public:
73 
74  void activateOptions(log4cxx::helpers::Pool&);
75 
76 
91  bool rollover(log4cxx::helpers::Pool& p);
92 
93  protected:
94 
98  virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
99 
100  protected:
101 
102  RollingPolicyPtr getRollingPolicy() const;
103 
104  TriggeringPolicyPtr getTriggeringPolicy() const;
105 
112  void setRollingPolicy(const RollingPolicyPtr& policy);
113 
114  void setTriggeringPolicy(const TriggeringPolicyPtr& policy);
115 
116  public:
120  void close();
121 
122  protected:
132  log4cxx::helpers::WriterPtr createWriter(log4cxx::helpers::OutputStreamPtr& os);
133 
134  public:
135 
136 
137 
142  size_t getFileLength() const;
143 
144 #ifdef LOG4CXX_MULTI_PROCESS
145 
149  void setFileLength(size_t length);
150 
155  void releaseFileLock(apr_file_t* lock_file);
160  void reopenLatestFile(log4cxx::helpers::Pool& p);
161 #endif
162 
167  void incrementFileLength(size_t increment);
168 
169 };
170 
171 
172 LOG4CXX_PTR_DEF(RollingFileAppenderSkeleton);
173 
174 }
175 }
176 
177 #endif
178 
Base class for log4cxx::rolling::RollingFileAppender and log4cxx::RollingFileAppender (analogues of o...
Definition: rollingfileappenderskeleton.h:40
FileAppender appends log events to a file.
Definition: fileappender.h:46
Definition: pool.h:32
Definition: appender.h:33