log4cplus
1.1.0
|
00001 // -*- C++ -*- 00002 // Module: Log4CPLUS 00003 // File: syslogappender.h 00004 // Created: 6/2001 00005 // Author: Tad E. Smith 00006 // 00007 // 00008 // Copyright 2001-2010 Tad E. Smith 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_SYSLOG_APPENDER_HEADER_ 00025 #define LOG4CPLUS_SYSLOG_APPENDER_HEADER_ 00026 00027 #include <log4cplus/config.hxx> 00028 00029 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 00030 #pragma once 00031 #endif 00032 00033 #include <log4cplus/appender.h> 00034 #include <log4cplus/helpers/socket.h> 00035 00036 00037 namespace log4cplus 00038 { 00039 00068 class LOG4CPLUS_EXPORT SysLogAppender : public Appender { 00069 public: 00070 // Ctors 00071 #if defined (LOG4CPLUS_HAVE_SYSLOG_H) 00072 SysLogAppender(const tstring& ident); 00073 #endif 00074 SysLogAppender(const tstring& ident, const tstring & host, 00075 int port = 514, const tstring & facility = tstring ()); 00076 SysLogAppender(const log4cplus::helpers::Properties & properties); 00077 00078 // Dtor 00079 virtual ~SysLogAppender(); 00080 00081 // Methods 00082 virtual void close(); 00083 00084 protected: 00085 virtual int getSysLogLevel(const LogLevel& ll) const; 00086 virtual void append(const spi::InternalLoggingEvent& event); 00087 #if defined (LOG4CPLUS_HAVE_SYSLOG_H) 00088 void appendLocal(const spi::InternalLoggingEvent& event); 00089 #endif 00090 void appendRemote(const spi::InternalLoggingEvent& event); 00091 00092 // Data 00093 tstring ident; 00094 int facility; 00095 00096 typedef void (SysLogAppender:: * AppendFuncType) ( 00097 const spi::InternalLoggingEvent&); 00098 AppendFuncType appendFunc; 00099 00100 tstring host; 00101 int port; 00102 helpers::Socket syslogSocket; 00103 00104 static tstring const remoteTimeFormat; 00105 00106 private: 00107 // Disallow copying of instances of this class 00108 SysLogAppender(const SysLogAppender&); 00109 SysLogAppender& operator=(const SysLogAppender&); 00110 00111 std::string identStr; 00112 tstring hostname; 00113 }; 00114 00115 } // end namespace log4cplus 00116 00117 00118 #endif // LOG4CPLUS_SYSLOG_APPENDER_HEADER_