log4cplus  1.1.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 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 
00057     class LOG4CPLUS_EXPORT Log4jUdpAppender : public Appender {
00058     public:
00059       // Ctors
00060         Log4jUdpAppender(const log4cplus::tstring& host, int port);
00061         Log4jUdpAppender(const log4cplus::helpers::Properties & properties);
00062 
00063       // Dtor
00064         ~Log4jUdpAppender();
00065 
00066       // Methods
00067         virtual void close();
00068 
00069     protected:
00070         void openSocket();
00071         virtual void append(const spi::InternalLoggingEvent& event);
00072 
00073       // Data
00074         log4cplus::helpers::Socket socket;
00075         log4cplus::tstring host;
00076         int port;
00077 
00078     private:
00079       // Disallow copying of instances of this class
00080         Log4jUdpAppender(const Log4jUdpAppender&);
00081         Log4jUdpAppender& operator=(const Log4jUdpAppender&);
00082     };
00083 } // end namespace log4cplus
00084 
00085 #endif // LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_
00086