RemoteSyslogAppender.hh
Go to the documentation of this file.
00001 /*
00002  * SyslogAppender.hh
00003  *
00004  * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00005  * Copyright 2001, Walter Stroebel. All rights reserved.
00006  *
00007  * See the COPYING file for the terms of usage and distribution.
00008  */
00009 
00010 #ifndef _LOG4CPP_REMOTESYSLOGAPPENDER_HH
00011 #define _LOG4CPP_REMOTESYSLOGAPPENDER_HH
00012 
00013 #include <log4cpp/Portability.hh>
00014 #include <string>
00015 #include <stdarg.h>
00016 #include <log4cpp/LayoutAppender.hh>
00017 #include <log4cpp/Priority.hh>
00018 #ifdef WIN32
00019 #include <winsock2.h>
00020 #else
00021 #include <netinet/in.h>
00022 #endif
00023 
00024 #ifdef LOG4CPP_HAVE_SYSLOG
00025 #include <syslog.h>
00026 #else
00027 
00028 typedef enum {
00029     LOG_EMERG   = 0,       
00030     LOG_ALERT   = 1,       
00031     LOG_CRIT    = 2,       
00032     LOG_ERR     = 3,       
00033     LOG_WARNING = 4,       
00034     LOG_NOTICE  = 5,       
00035     LOG_INFO    = 6,       
00036     LOG_DEBUG   = 7,       
00037 } SyslogLevel;
00038 
00039 typedef enum {
00040     LOG_KERN     = (0<<3),  
00041     LOG_USER     = (1<<3),  
00042     LOG_MAIL     = (2<<3),  
00043     LOG_DAEMON   = (3<<3),  
00044     LOG_AUTH     = (4<<3),  
00045     LOG_SYSLOG   = (5<<3),  
00046     LOG_LPR      = (6<<3),  
00047     LOG_NEWS     = (7<<3),  
00048     LOG_UUCP     = (8<<3),  
00049     LOG_CRON     = (9<<3),  
00050     LOG_AUTHPRIV = (10<<3), 
00051     LOG_FTP      = (11<<3), 
00052     
00053     /* other codes through 15 reserved for system use */ 
00054     LOG_LOCAL0   = (16<<3), 
00055     LOG_LOCAL1   = (17<<3), 
00056     LOG_LOCAL2   = (18<<3), 
00057     LOG_LOCAL3   = (19<<3), 
00058     LOG_LOCAL4   = (20<<3), 
00059     LOG_LOCAL5   = (21<<3), 
00060     LOG_LOCAL6   = (22<<3), 
00061     LOG_LOCAL7   = (23<<3), 
00062 } SyslogFacility;
00063 #endif
00064 
00065 namespace log4cpp {
00066 
00072     class LOG4CPP_EXPORT RemoteSyslogAppender : public LayoutAppender {
00073         public:
00074 
00080         static int toSyslogPriority(Priority::Value priority);
00081 
00094         RemoteSyslogAppender(const std::string& name, 
00095                              const std::string& syslogName, 
00096                              const std::string& relayer, 
00097                              int facility = LOG_USER,
00098                              int portNumber = 514);
00099         virtual ~RemoteSyslogAppender();
00100 
00104         virtual bool reopen();
00105 
00109         virtual void close();
00110 
00111         protected:
00112         
00116         virtual void open();
00117 
00122         virtual void _append(const LoggingEvent& event);
00123 
00124         const std::string _syslogName;
00125         const std::string _relayer;
00126         int _facility;
00127         int _portNumber;
00128 #ifdef  WIN32
00129                 SOCKET  _socket;
00130 #else   
00131                 int             _socket;
00132 #endif
00133         in_addr_t _ipAddr;
00134         private:
00135         int _cludge;
00136     };
00137 }
00138 
00139 #endif // _LOG4CPP_REMOTESYSLOGAPPENDER_HH


log4cpp
Author(s): Stephen Roderick
autogenerated on Mon Oct 6 2014 03:13:14