log4cpp  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RemoteSyslogAppender.hh
Go to the documentation of this file.
1 /*
2  * SyslogAppender.hh
3  *
4  * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5  * Copyright 2001, Walter Stroebel. All rights reserved.
6  *
7  * See the COPYING file for the terms of usage and distribution.
8  */
9 
10 #ifndef _LOG4CPP_REMOTESYSLOGAPPENDER_HH
11 #define _LOG4CPP_REMOTESYSLOGAPPENDER_HH
12 
13 #include <log4cpp/Portability.hh>
14 #include <string>
15 #include <stdarg.h>
17 #include <log4cpp/Priority.hh>
18 #ifdef WIN32
19 #include <winsock2.h>
20 #else
21 #include <netinet/in.h>
22 #endif
23 
24 #ifdef LOG4CPP_HAVE_SYSLOG
25 #include <syslog.h>
26 #else
27 typedef enum {
29  LOG_EMERG = 0,
30  LOG_ALERT = 1,
31  LOG_CRIT = 2,
32  LOG_ERR = 3,
34  LOG_NOTICE = 5,
35  LOG_INFO = 6,
36  LOG_DEBUG = 7,
37 } SyslogLevel;
38 
39 typedef enum {
40  LOG_KERN = (0<<3),
41  LOG_USER = (1<<3),
42  LOG_MAIL = (2<<3),
43  LOG_DAEMON = (3<<3),
44  LOG_AUTH = (4<<3),
45  LOG_SYSLOG = (5<<3),
46  LOG_LPR = (6<<3),
47  LOG_NEWS = (7<<3),
48  LOG_UUCP = (8<<3),
49  LOG_CRON = (9<<3),
50  LOG_AUTHPRIV = (10<<3),
51  LOG_FTP = (11<<3),
52 
53  /* other codes through 15 reserved for system use */
54  LOG_LOCAL0 = (16<<3),
55  LOG_LOCAL1 = (17<<3),
56  LOG_LOCAL2 = (18<<3),
57  LOG_LOCAL3 = (19<<3),
58  LOG_LOCAL4 = (20<<3),
59  LOG_LOCAL5 = (21<<3),
60  LOG_LOCAL6 = (22<<3),
61  LOG_LOCAL7 = (23<<3),
63 #endif
64 
65 namespace log4cpp {
66 
73  public:
74 
80  static int toSyslogPriority(Priority::Value priority);
81 
94  RemoteSyslogAppender(const std::string& name,
95  const std::string& syslogName,
96  const std::string& relayer,
97  int facility = LOG_USER,
98  int portNumber = 514);
99  virtual ~RemoteSyslogAppender();
100 
104  virtual bool reopen();
105 
109  virtual void close();
110 
111  protected:
112 
116  virtual void open();
117 
122  virtual void _append(const LoggingEvent& event);
123 
124  const std::string _syslogName;
125  const std::string _relayer;
128 #ifdef WIN32
129  SOCKET _socket;
130 #else
131  int _socket;
132 #endif
133  in_addr_t _ipAddr;
134  private:
135  int _cludge;
136  };
137 }
138 
139 #endif // _LOG4CPP_REMOTESYSLOGAPPENDER_HH