Apache log4cxx  Version 0.12.1
sockethubappender.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_HUB_APPENDER_H
19 #define _LOG4CXX_NET_SOCKET_HUB_APPENDER_H
20 
21 #if defined(_MSC_VER)
22  #pragma warning ( push )
23  #pragma warning ( disable: 4231 4251 4275 4786 )
24 #endif
25 
26 
28 #include <vector>
29 #include <thread>
31 
32 
33 namespace log4cxx
34 {
35 namespace helpers
36 {
38 typedef std::shared_ptr<ObjectOutputStream> ObjectOutputStreamPtr;
39 }
40 namespace net
41 {
43 
109 class LOG4CXX_EXPORT SocketHubAppender : public AppenderSkeleton
110 {
111  private:
115  static int DEFAULT_PORT;
116 
117  int port;
118  ObjectOutputStreamList streams;
119  bool locationInfo;
120 
121  public:
127 
130 
134  SocketHubAppender(int port) ;
135 
139  virtual void activateOptions(log4cxx::helpers::Pool& p);
140 
144  virtual void setOption(const LogString& option, const LogString& value);
145 
146  virtual void close();
147 
150  virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
151 
155  virtual bool requiresLayout() const
156  {
157  return false;
158  }
159 
163  inline void setPort(int port1)
164  {
165  this->port = port1;
166  }
167 
170  inline int getPort() const
171  {
172  return port;
173  }
174 
179  inline void setLocationInfo(bool locationInfo1)
180  {
181  this->locationInfo = locationInfo1;
182  }
183 
186  inline bool getLocationInfo() const
187  {
188  return locationInfo;
189  }
190 
193  private:
194  void startServer();
195 
196  std::thread thread;
197  void monitor();
198 
199 }; // class SocketHubAppender
201 } // namespace net
202 } // namespace log4cxx
203 
204 
205 #if defined(_MSC_VER)
206  #pragma warning ( pop )
207 #endif
208 
209 #endif // _LOG4CXX_NET_SOCKET_HUB_APPENDER_H
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:148
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
Implementation base class for all appenders.
Definition: appenderskeleton.h:43
LOG4CXX_PTR_DEF(AppenderAttachableImpl)
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:37
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
LOG4CXX_LIST_DEF(ByteList, unsigned char)
void setLocationInfo(bool locationInfo1)
The LocationInfo option takes a boolean value.
Definition: sockethubappender.h:179
void setPort(int port1)
The Port option takes a positive integer representing the port where the server is waiting for connec...
Definition: sockethubappender.h:163
virtual bool requiresLayout() const
The SocketHubAppender does not use a layout.
Definition: sockethubappender.h:155
Sends LoggingEvent objects to a set of remote log servers, usually a SocketNode.
Definition: sockethubappender.h:109
std::shared_ptr< ObjectOutputStream > ObjectOutputStreamPtr
Definition: sockethubappender.h:37
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
Emulates java serialization.
Definition: objectoutputstream.h:33
int getPort() const
Returns value of the Port option.
Definition: sockethubappender.h:170
Definition: pool.h:32
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:154
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66
bool getLocationInfo() const
Returns value of the LocationInfo option.
Definition: sockethubappender.h:186