Apache Log4cxx  Version 1.5.0
socketappenderskeleton.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_NET_SOCKET_APPENDER_SKELETON_H
19 #define _LOG4CXX_NET_SOCKET_APPENDER_SKELETON_H
20 
22 #include <log4cxx/helpers/socket.h>
23 #include <thread>
24 #include <condition_variable>
25 
26 namespace LOG4CXX_NS
27 {
28 
29 namespace net
30 {
31 
35 class LOG4CXX_EXPORT SocketAppenderSkeleton : public AppenderSkeleton
36 {
37  protected:
38  struct SocketAppenderSkeletonPriv;
39 
40  public:
41  SocketAppenderSkeleton(int defaultPort, int reconnectionDelay);
43 
47  SocketAppenderSkeleton(helpers::InetAddressPtr address, int port, int reconnectionDelay);
48 
52  SocketAppenderSkeleton(const LogString& host, int port, int reconnectionDelay);
53 
59  void activateOptions(helpers::Pool& p) override;
60 
61  void close() override;
62 
63 
69  bool requiresLayout() const override
70  {
71  return false;
72  }
73 
79  void setRemoteHost(const LogString& host);
80 
84  const LogString& getRemoteHost() const;
85 
90  void setPort(int port1);
91 
95  int getPort() const;
96 
102  void setLocationInfo(bool locationInfo1);
103 
107  bool getLocationInfo() const;
108 
118  void setReconnectionDelay(int reconnectionDelay1);
119 
123  int getReconnectionDelay() const;
124 
126 
142  void setOption(const LogString& option, const LogString& value) override;
143 
144  protected:
145  SocketAppenderSkeleton(std::unique_ptr<SocketAppenderSkeletonPriv> priv);
146 
147  virtual void setSocket(LOG4CXX_NS::helpers::SocketPtr& socket, LOG4CXX_NS::helpers::Pool& p) = 0;
148 
149  virtual void cleanUp(LOG4CXX_NS::helpers::Pool& p) = 0;
150 
151  virtual int getDefaultDelay() const = 0;
152 
153  virtual int getDefaultPort() const = 0;
154 
155  private:
156  void connect(LOG4CXX_NS::helpers::Pool& p);
167  void retryConnect();
168  bool is_closed();
171 
172 }; // class SocketAppenderSkeleton
173 } // namespace net
174 } // namespace log4cxx
175 
176 #endif // _LOG4CXX_NET_SOCKET_APPENDER_SKELETON_H
177 
log4cxx::net::SocketAppenderSkeleton::setLocationInfo
void setLocationInfo(bool locationInfo1)
The LocationInfo option takes a boolean value.
log4cxx::net::SocketAppenderSkeleton::setPort
void setPort(int port1)
The Port option takes a positive integer representing the port where the server is waiting for connec...
log4cxx::LogString
std::basic_string< logchar > LogString
Definition: logstring.h:60
log4cxx::net::SocketAppenderSkeleton::getDefaultPort
virtual int getDefaultPort() const =0
log4cxx::net::SocketAppenderSkeleton::setOption
void setOption(const LogString &option, const LogString &value) override
Set option to value.
log4cxx::net::SocketAppenderSkeleton::SocketAppenderSkeleton
SocketAppenderSkeleton(helpers::InetAddressPtr address, int port, int reconnectionDelay)
Connects to remote server at address and port.
log4cxx::net::SocketAppenderSkeleton::getReconnectionDelay
int getReconnectionDelay() const
Returns value of the ReconnectionDelay option.
log4cxx::net::SocketAppenderSkeleton::setReconnectionDelay
void setReconnectionDelay(int reconnectionDelay1)
The ReconnectionDelay option takes a positive integer representing the number of milliseconds to wait...
log4cxx::net::SocketAppenderSkeleton::getDefaultDelay
virtual int getDefaultDelay() const =0
log4cxx::net::SocketAppenderSkeleton::fireConnector
void fireConnector()
log4cxx::net::SocketAppenderSkeleton::setRemoteHost
void setRemoteHost(const LogString &host)
The RemoteHost option takes a string value which should be the host name of the server where a Apache...
log4cxx::net::SocketAppenderSkeleton::getRemoteHost
const LogString & getRemoteHost() const
Returns value of the RemoteHost option.
log4cxx::net::SocketAppenderSkeleton
Abstract base class for SocketAppender and XMLSocketAppender.
Definition: socketappenderskeleton.h:36
log4cxx::net::SocketAppenderSkeleton::getLocationInfo
bool getLocationInfo() const
Returns value of the LocationInfo option.
log4cxx::net::SocketAppenderSkeleton::setSocket
virtual void setSocket(log4cxx::helpers::SocketPtr &socket, log4cxx::helpers::Pool &p)=0
log4cxx::net::SocketAppenderSkeleton::~SocketAppenderSkeleton
~SocketAppenderSkeleton()
log4cxx::net::SocketAppenderSkeleton::getPort
int getPort() const
Returns value of the Port option.
log4cxx::AppenderSkeleton
Implementation base class for all appenders.
Definition: appenderskeleton.h:41
log4cxx::net::SocketAppenderSkeleton::activateOptions
void activateOptions(helpers::Pool &p) override
Activate the options that were previously set with calls to option setters.
log4cxx::net::SocketAppenderSkeleton::SocketAppenderSkeleton
SocketAppenderSkeleton(const LogString &host, int port, int reconnectionDelay)
Connects to remote server at host and port.
log4cxx::net::SocketAppenderSkeleton::SocketAppenderSkeleton
SocketAppenderSkeleton(int defaultPort, int reconnectionDelay)
appenderskeleton.h
socket.h
log4cxx::net::SocketAppenderSkeleton::close
void close() override
Release any resources allocated within the appender such as file handles, network connections,...
log4cxx::helpers::Pool
Definition: pool.h:33
log4cxx::net::SocketAppenderSkeleton::SocketAppenderSkeleton
SocketAppenderSkeleton(std::unique_ptr< SocketAppenderSkeletonPriv > priv)
log4cxx::net::SocketAppenderSkeleton::cleanUp
virtual void cleanUp(log4cxx::helpers::Pool &p)=0
log4cxx::net::SocketAppenderSkeleton::requiresLayout
bool requiresLayout() const override
This appender does not use a layout.
Definition: socketappenderskeleton.h:69