Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

socketappender.h

Go to the documentation of this file.
00001 // Module:  LOG4CPLUS
00002 // File:    socketappender.h
00003 // Created: 5/2003
00004 // Author:  Tad E. Smith
00005 //
00006 //
00007 // Copyright (C) Tad E. Smith  All rights reserved.
00008 //
00009 // This software is published under the terms of the Apache Software
00010 // License version 1.1, a copy of which has been included with this
00011 // distribution in the LICENSE.APL file.
00012 //
00013 
00016 #ifndef _LOG4CPLUS_SOCKET_APPENDER_HEADER_
00017 #define _LOG4CPLUS_SOCKET_APPENDER_HEADER_
00018 
00019 #include <log4cplus/config.h>
00020 #include <log4cplus/appender.h>
00021 #include <log4cplus/helpers/socket.h>
00022 
00023 #ifndef UNICODE
00024 #  define LOG4CPLUS_MAX_MESSAGE_SIZE (8*1024)
00025 #else
00026 #  define LOG4CPLUS_MAX_MESSAGE_SIZE (2*8*1024)
00027 #endif
00028 
00029 
00030 namespace log4cplus {
00031 
00068     class LOG4CPLUS_EXPORT SocketAppender : public Appender {
00069     public:
00070       // Ctors
00071         SocketAppender(const log4cplus::tstring& host, int port, 
00072                        const log4cplus::tstring& serverName = tstring());
00073         SocketAppender(const log4cplus::helpers::Properties properties);
00074 
00075       // Dtor
00076         ~SocketAppender();
00077 
00078       // Methods
00079         virtual void close();
00080 
00081     protected:
00082         void openSocket();
00083         virtual void append(const spi::InternalLoggingEvent& event);
00084 
00085       // Data
00086         log4cplus::helpers::Socket socket;
00087         log4cplus::tstring host;
00088         int port;
00089         log4cplus::tstring serverName;
00090 
00091     private:
00092       // Disallow copying of instances of this class
00093         SocketAppender(const SocketAppender&);
00094         SocketAppender& operator=(const SocketAppender&);
00095     };
00096 
00097     namespace helpers {
00098         LOG4CPLUS_EXPORT
00099         SocketBuffer convertToBuffer(const log4cplus::spi::InternalLoggingEvent& event,
00100                                      const log4cplus::tstring& serverName);
00101 
00102         LOG4CPLUS_EXPORT
00103         log4cplus::spi::InternalLoggingEvent readFromBuffer(SocketBuffer& buffer);
00104     } // end namespace helpers
00105 
00106 } // end namespace log4cplus
00107 
00108 #endif // _LOG4CPLUS_SOCKET_APPENDER_HEADER_
00109 

Generated on Mon Feb 9 09:10:30 2004 for log4cplus by doxygen 1.3.2