Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
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
25namespace LOG4CXX_NS
26{
27
31class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton
32{
33 protected:
34 struct WriterAppenderPriv;
35 public:
41
42
45 protected:
46 WriterAppender(const LayoutPtr& layout, const helpers::WriterPtr& writer = helpers::WriterPtr());
47 WriterAppender(std::unique_ptr<WriterAppenderPriv> priv);
48
49 public:
51
57 void activateOptions( ) override;
58
73 void setImmediateFlush(bool value);
77 bool getImmediateFlush() const;
78
91 void append( const spi::LoggingEventPtr& event ) override;
92
93
94 protected:
101 virtual bool checkEntryConditions() const;
102
103
104 public:
111 void close() override;
112
113 protected:
114
121 virtual helpers::WriterPtr createWriter(const helpers::OutputStreamPtr& os);
122
123 public:
135 void setEncoding(const LogString& value);
136
146 void setOption(const LogString& option, const LogString& value) override;
147
148
149 bool requiresLayout() const override;
150
151 protected:
155 virtual void subAppend( const spi::LoggingEventPtr& event );
156
157
158 private:
159 //
160 // prevent copy and assignment
162 WriterAppender& operator=(const WriterAppender&);
163};
164
166
167} //namespace log4cxx
168
169#endif //_LOG4CXX_WRITER_APPENDER_H
AppenderSkeleton(LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv)
WriterAppender appends log events to a standard output stream.
Definition writerappender.h:32
void activateOptions() override
Derived appenders should override this method if option structure requires it.
LogString getEncoding() const
The current encoding value.
void setOption(const LogString &option, const LogString &value) override
Set option to value.
virtual void subAppend(const spi::LoggingEventPtr &event)
Actual writing occurs here.
void setImmediateFlush(bool value)
If the ImmediateFlush option is set to true, the appender will flush at the end of each write.
void append(const spi::LoggingEventPtr &event) override
This method is called by the AppenderSkeleton::doAppend method.
bool requiresLayout() const override
Configurators call this method to determine if the appender requires a layout.
bool getImmediateFlush() const
Returns value of the ImmediateFlush option.
void close() override
Close this appender instance.
virtual bool checkEntryConditions() const
This method determines if there is a sense in attempting to append.
void setEncoding(const LogString &value)
Set the encoding to value.
WriterAppender()
This default constructor does nothing.
virtual helpers::WriterPtr createWriter(const helpers::OutputStreamPtr &os)
Returns an OutputStreamWriter when passed an OutputStream.
Definition propertysetter.h:27
Definition appender.h:30
std::basic_string< logchar > LogString
Definition logstring.h:51
std::shared_ptr< Layout > LayoutPtr
Definition appender.h:42
LOG4CXX_PTR_DEF(Appender)
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:154
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition object.h:37
#define END_LOG4CXX_CAST_MAP()
Definition object.h:148
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition object.h:160
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:142