Apache Log4cxx  Version 1.7.0
Loading...
Searching...
No Matches
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
23#include <thread>
24#include <condition_variable>
25
26namespace LOG4CXX_NS
27{
28
29namespace net
30{
31
35class 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
61
62 void close() override;
63
64
70 bool requiresLayout() const override
71 {
72 return false;
73 }
74
80 void setRemoteHost(const LogString& host);
81
85 const LogString& getRemoteHost() const;
86
91 void setPort(int port1);
92
96 int getPort() const;
97
103 void setLocationInfo(bool locationInfo1);
104
108 bool getLocationInfo() const;
109
119 void setReconnectionDelay(int reconnectionDelay1);
120
125
127
143 void setOption(const LogString& option, const LogString& value) override;
144
145 protected:
146 SocketAppenderSkeleton(std::unique_ptr<SocketAppenderSkeletonPriv> priv);
147
148 virtual void setSocket(LOG4CXX_NS::helpers::SocketPtr& socket, LOG4CXX_NS::helpers::Pool& p) = 0;
149
150#if LOG4CXX_ABI_VERSION <= 15
151 virtual void cleanUp(LOG4CXX_NS::helpers::Pool& p) = 0;
152#endif
153 virtual int getDefaultDelay() const = 0;
154
155 virtual int getDefaultPort() const = 0;
156
157 private:
158 void connect(LOG4CXX_NS::helpers::Pool& p);
168
169 void retryConnect();
170 bool is_closed();
173
174}; // class SocketAppenderSkeleton
175} // namespace net
176} // namespace log4cxx
177
178#endif // _LOG4CXX_NET_SOCKET_APPENDER_SKELETON_H
179
AppenderSkeleton(LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv)
void close() override
Release any resources allocated within the appender such as file handles, network connections,...
virtual void cleanUp(log4cxx::helpers::Pool &1)=0
SocketAppenderSkeleton(int defaultPort, int reconnectionDelay)
bool requiresLayout() const override
This appender does not use a layout.
Definition socketappenderskeleton.h:70
SocketAppenderSkeleton(std::unique_ptr< SocketAppenderSkeletonPriv > priv)
SocketAppenderSkeleton(const LogString &host, int port, int reconnectionDelay)
Connects to remote server at host and port.
bool getLocationInfo() const
Returns value of the LocationInfo option.
int getReconnectionDelay() const
Returns value of the ReconnectionDelay option.
SocketAppenderSkeleton(helpers::InetAddressPtr address, int port, int reconnectionDelay)
Connects to remote server at address and port.
void setPort(int port1)
The Port option takes a positive integer representing the port where the server is waiting for connec...
void activateOptions(helpers::Pool &) override
int getPort() const
Returns value of the Port option.
void setReconnectionDelay(int reconnectionDelay1)
The ReconnectionDelay option takes a positive integer representing the number of milliseconds to wait...
virtual void setSocket(log4cxx::helpers::SocketPtr &socket, log4cxx::helpers::Pool &1)=0
void setRemoteHost(const LogString &host)
The RemoteHost option takes a string value which should be the host name of the server where a Apache...
const LogString & getRemoteHost() const
Returns value of the RemoteHost option.
void setOption(const LogString &option, const LogString &value) override
Set option to value.
virtual int getDefaultDelay() const =0
void setLocationInfo(bool locationInfo1)
The LocationInfo option takes a boolean value.
virtual int getDefaultPort() const =0
std::basic_string< logchar > LogString
Definition logstring.h:60
#define LOG4CXX_ACTIVATE_OPTIONS_FORMAL_PARAMETERS
Activate the options that were previously set with calls to option setters.
Definition optionhandler.h:53