log4cplus  2.0.0
log4judpappender.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Module:  LOG4CPLUS
00003 // File:    log4judpappender.h
00004 // Created: 7/2012
00005 // Author:  Siva Chandran P
00006 //
00007 //
00008 // Copyright 2012-2015 Siva Chandran P
00009 //
00010 // Licensed under the Apache License, Version 2.0 (the "License");
00011 // you may not use this file except in compliance with the License.
00012 // You may obtain a copy of the License at
00013 //
00014 //     http://www.apache.org/licenses/LICENSE-2.0
00015 //
00016 // Unless required by applicable law or agreed to in writing, software
00017 // distributed under the License is distributed on an "AS IS" BASIS,
00018 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019 // See the License for the specific language governing permissions and
00020 // limitations under the License.
00021 
00024 #ifndef LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_
00025 #define LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_
00026 
00027 #include <log4cplus/config.hxx>
00028 #include <log4cplus/appender.h>
00029 #include <log4cplus/helpers/socket.h>
00030 
00031 namespace log4cplus {
00032 
00061     class LOG4CPLUS_EXPORT Log4jUdpAppender : public Appender {
00062     public:
00063       // Ctors
00064         Log4jUdpAppender(const log4cplus::tstring& host, int port,
00065             bool ipv6 = false);
00066         Log4jUdpAppender(const log4cplus::helpers::Properties & properties);
00067 
00068       // Dtor
00069         ~Log4jUdpAppender();
00070 
00071       // Methods
00072         virtual void close();
00073 
00074     protected:
00075         void openSocket();
00076         virtual void append(const spi::InternalLoggingEvent& event);
00077 
00078       // Data
00079         log4cplus::helpers::Socket socket;
00080         log4cplus::tstring host;
00081         int port;
00082         bool ipv6 = false;
00083 
00084     private:
00085       // Disallow copying of instances of this class
00086         Log4jUdpAppender(const Log4jUdpAppender&);
00087         Log4jUdpAppender& operator=(const Log4jUdpAppender&);
00088     };
00089 } // end namespace log4cplus
00090 
00091 #endif // LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_