Apache log4cxx  Version 0.13.0
telnetappender.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_TELNET_APPENDER_H
19 #define _LOG4CXX_NET_TELNET_APPENDER_H
20 
21 #if defined(_MSC_VER)
22  #pragma warning ( push )
23  #pragma warning ( disable: 4231 4251 4275 4786 )
24 #endif
25 
26 
27 
29 #include <log4cxx/helpers/socket.h>
31 #include <thread>
32 #include <vector>
34 
35 namespace log4cxx
36 {
37 namespace helpers
38 {
39 class ByteBuffer;
40 }
41 namespace net
42 {
43 typedef log4cxx::helpers::SocketPtr Connection;
44 LOG4CXX_LIST_DEF(ConnectionList, Connection);
45 
71 class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton
72 {
73  class SocketHandler;
74  friend class SocketHandler;
75  private:
76  static const int DEFAULT_PORT;
77  static const int MAX_CONNECTIONS;
78  int port;
79 
80  public:
86 
88  ~TelnetAppender();
89 
93  virtual bool requiresLayout() const
94  {
95  return true;
96  }
97 
98  LogString getEncoding() const;
99  void setEncoding(const LogString& value);
100 
101 
104  void activateOptions(log4cxx::helpers::Pool& p);
105 
109  virtual void setOption(const LogString& option, const LogString& value);
110 
114  int getPort() const
115  {
116  return port;
117  }
118 
123  void setPort(int port1)
124  {
125  this->port = port1;
126  }
127 
128 
130  void close();
131 
132  protected:
135  virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) ;
136 
137  //---------------------------------------------------------- SocketHandler:
138 
139  private:
140  // prevent copy and assignment statements
142  TelnetAppender& operator=(const TelnetAppender&);
143 
144  void write(log4cxx::helpers::ByteBuffer&);
145  void writeStatus(const log4cxx::helpers::SocketPtr& socket, const LogString& msg, log4cxx::helpers::Pool& p);
146  ConnectionList connections;
147  LogString encoding;
148  log4cxx::helpers::CharsetEncoderPtr encoder;
149  helpers::ServerSocket* serverSocket;
150  std::thread sh;
151  size_t activeConnections;
152  void acceptConnections();
153 }; // class TelnetAppender
154 
156 } // namespace net
157 } // namespace log4cxx
158 
159 
160 #if defined(_MSC_VER)
161  #pragma warning ( pop )
162 #endif
163 
164 #endif // _LOG4CXX_NET_TELNET_APPENDER_H
165 
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:153
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:147
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:141
LOG4CXX_LIST_DEF(ByteList, unsigned char)
Definition: telnetappender.h:71
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
Definition: serversocket.h:28
log4cxx::helpers::SocketPtr Connection
Definition: telnetappender.h:43
Definition: pool.h:32
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:159
A byte buffer.
Definition: bytebuffer.h:33
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66
int getPort() const
Returns value of the Port option.
Definition: telnetappender.h:114
void setPort(int port1)
The Port option takes a positive integer representing the port where the server is waiting for connec...
Definition: telnetappender.h:123