source: pacpusframework/trunk/3rd/apache-log4cxx/include/log4cxx/rolling/rollingfileappenderskeleton.h@ 84

Last change on this file since 84 was 2, checked in by sgosseli, 12 years ago

Add 3rd party libraries (log4cxx).

File size: 5.0 KB
Line 
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
28namespace log4cxx {
29 namespace rolling {
30
31
32 /**
33 * Base class for log4cxx::rolling::RollingFileAppender and log4cxx::RollingFileAppender
34 * (analogues of org.apache.log4j.rolling.RFA from extras companion and
35 * org.apache.log4j.RFA from log4j 1.2, respectively).
36 *
37 * */
38 class LOG4CXX_EXPORT RollingFileAppenderSkeleton : public FileAppender {
39 DECLARE_LOG4CXX_OBJECT(RollingFileAppenderSkeleton)
40 BEGIN_LOG4CXX_CAST_MAP()
41 LOG4CXX_CAST_ENTRY(RollingFileAppenderSkeleton)
42 LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
43 END_LOG4CXX_CAST_MAP()
44
45 /**
46 * Triggering policy.
47 */
48 TriggeringPolicyPtr triggeringPolicy;
49
50 /**
51 * Rolling policy.
52 */
53 RollingPolicyPtr rollingPolicy;
54
55 /**
56 * Length of current active log file.
57 */
58 size_t fileLength;
59
60 public:
61 /**
62 * The default constructor simply calls its {@link
63 * FileAppender#FileAppender parents constructor}.
64 * */
65 RollingFileAppenderSkeleton();
66
67 void activateOptions(log4cxx::helpers::Pool&);
68
69
70 /**
71 Implements the usual roll over behaviour.
72
73 <p>If <code>MaxBackupIndex</code> is positive, then files
74 {<code>File.1</code>, ..., <code>File.MaxBackupIndex -1</code>}
75 are renamed to {<code>File.2</code>, ...,
76 <code>File.MaxBackupIndex</code>}. Moreover, <code>File</code> is
77 renamed <code>File.1</code> and closed. A new <code>File</code> is
78 created to receive further log output.
79
80 <p>If <code>MaxBackupIndex</code> is equal to zero, then the
81 <code>File</code> is truncated with no backup files created.
82
83 */
84 bool rollover(log4cxx::helpers::Pool& p);
85
86 protected:
87
88 /**
89 Actual writing occurs here.
90 */
91 virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
92
93 protected:
94
95 RollingPolicyPtr getRollingPolicy() const;
96
97 TriggeringPolicyPtr getTriggeringPolicy() const;
98
99 /**
100 * Sets the rolling policy. In case the 'policy' argument also implements
101 * {@link TriggeringPolicy}, then the triggering policy for this appender
102 * is automatically set to be the policy argument.
103 * @param policy
104 */
105 void setRollingPolicy(const RollingPolicyPtr& policy);
106
107 void setTriggeringPolicy(const TriggeringPolicyPtr& policy);
108
109 public:
110 /**
111 * Close appender. Waits for any asynchronous file compression actions to be completed.
112 */
113 void close();
114
115 protected:
116 /**
117 Returns an OutputStreamWriter when passed an OutputStream. The
118 encoding used will depend on the value of the
119 <code>encoding</code> property. If the encoding value is
120 specified incorrectly the writer will be opened using the default
121 system encoding (an error message will be printed to the loglog.
122 @param os output stream, may not be null.
123 @return new writer.
124 */
125 log4cxx::helpers::WriterPtr createWriter(log4cxx::helpers::OutputStreamPtr& os);
126
127 public:
128
129
130
131 /**
132 * Get byte length of current active log file.
133 * @return byte length of current active log file.
134 */
135 size_t getFileLength() const;
136
137 /**
138 * Increments estimated byte length of current active log file.
139 * @param increment additional bytes written to log file.
140 */
141 void incrementFileLength(size_t increment);
142
143 };
144
145
146 LOG4CXX_PTR_DEF(RollingFileAppenderSkeleton);
147
148 }
149}
150
151#endif
152
Note: See TracBrowser for help on using the repository browser.