Apache Log4cxx  Version 1.1.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 
22 #include <log4cxx/helpers/socket.h>
24 #include <thread>
25 #include <vector>
27 
28 namespace log4cxx
29 {
30 namespace helpers
31 {
32 class ByteBuffer;
33 }
34 namespace net
35 {
36 typedef log4cxx::helpers::SocketPtr Connection;
37 LOG4CXX_LIST_DEF(ConnectionList, Connection);
38 
64 class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton
65 {
66  class SocketHandler;
67  friend class SocketHandler;
68  private:
69  static const int DEFAULT_PORT;
70  static const int MAX_CONNECTIONS;
71 
72  public:
78 
81 
85  bool requiresLayout() const override
86  {
87  return true;
88  }
89 
91  void setEncoding(const LogString& value);
92 
93 
96  void activateOptions(helpers::Pool& p) override;
97 
101  void setOption(const LogString& option, const LogString& value) override;
102 
106  int getPort() const;
107 
112  void setPort(int port1);
113 
114 
116  void close() override;
117 
118  protected:
121  void append(const spi::LoggingEventPtr& event, helpers::Pool& p) override;
122 
123  //---------------------------------------------------------- SocketHandler:
124 
125  private:
126  // prevent copy and assignment statements
128  TelnetAppender& operator=(const TelnetAppender&);
129 
130  void write(log4cxx::helpers::ByteBuffer&);
131  void writeStatus(const log4cxx::helpers::SocketPtr& socket, const LogString& msg, log4cxx::helpers::Pool& p);
132  void acceptConnections();
133 
134  struct TelnetAppenderPriv;
135 }; // class TelnetAppender
136 
138 } // namespace net
139 } // namespace log4cxx
140 
141 #endif // _LOG4CXX_NET_TELNET_APPENDER_H
142 
Implementation base class for all appenders.
Definition: appenderskeleton.h:41
A byte buffer.
Definition: bytebuffer.h:34
Definition: pool.h:33
Definition: telnetappender.h:65
void close() override
shuts down the appender.
void activateOptions(helpers::Pool &p) override
all of the options have been set, create the socket handler and wait for connections.
void append(const spi::LoggingEventPtr &event, helpers::Pool &p) override
Handles a log event.
void setPort(int port1)
The Port option takes a positive integer representing the port where the server is waiting for connec...
void setOption(const LogString &option, const LogString &value) override
Set options.
LogString getEncoding() const
int getPort() const
Returns value of the Port option.
void setEncoding(const LogString &value)
LOG4CXX_LIST_DEF(ConnectionList, Connection)
log4cxx::helpers::SocketPtr Connection
Definition: telnetappender.h:36
LOG4CXX_PTR_DEF(SMTPAppender)
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:31
Definition: appender.h:27
std::basic_string< logchar > LogString
Definition: logstring.h:60
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:157
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:151
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:42
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:163
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:145