Apache Log4cxx  Version 1.1.0
writerappender.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 #ifndef _LOG4CXX_WRITER_APPENDER_H
19 #define _LOG4CXX_WRITER_APPENDER_H
20 
23 #include <atomic>
24 
25 namespace log4cxx
26 {
27 
28 namespace helpers
29 {
30 class Transcoder;
31 }
32 
36 class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton
37 {
38  protected:
39  struct WriterAppenderPriv;
40  public:
46 
47 
50  protected:
51  WriterAppender(const LayoutPtr& layout,
52  log4cxx::helpers::WriterPtr& writer);
53  WriterAppender(const LayoutPtr& layout);
54  WriterAppender(std::unique_ptr<WriterAppenderPriv> priv);
55 
56  public:
58 
63  void activateOptions(helpers::Pool& pool) override;
64 
79  void setImmediateFlush(bool value);
83  bool getImmediateFlush() const;
84 
97  void append(const spi::LoggingEventPtr& event, helpers::Pool& p) override;
98 
99 
100  protected:
107  virtual bool checkEntryConditions() const;
108 
109 
110  public:
117  void close() override;
118 
119  protected:
123  void closeWriter();
124 
131  virtual helpers::WriterPtr createWriter(helpers::OutputStreamPtr& os);
132 
133  public:
134  LogString getEncoding() const;
135  void setEncoding(const LogString& value);
136  void setOption(const LogString& option, const LogString& value) override;
137 
150  void setWriter(const log4cxx::helpers::WriterPtr& writer);
151 
152  const log4cxx::helpers::WriterPtr getWriter() const;
153 
154  bool requiresLayout() const override;
155 
156  protected:
160  virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
161 
162 
166  virtual void writeFooter(log4cxx::helpers::Pool& p);
167 
171  virtual void writeHeader(log4cxx::helpers::Pool& p);
172 
176  void setWriterInternal(const log4cxx::helpers::WriterPtr& writer);
177 
178  private:
179  //
180  // prevent copy and assignment
182  WriterAppender& operator=(const WriterAppender&);
183 };
184 
186 
187 } //namespace log4cxx
188 
189 #endif //_LOG4CXX_WRITER_APPENDER_H
Implementation base class for all appenders.
Definition: appenderskeleton.h:41
WriterAppender appends log events to a standard output stream.
Definition: writerappender.h:37
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:31
Definition: appender.h:27
std::basic_string< logchar > LogString
Definition: logstring.h:60
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:41
LOG4CXX_PTR_DEF(Appender)
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:157
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:38
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:151
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:163
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:145