log4shib 2.0.0

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 _LOG4SHIB_REMOTESYSLOGAPPENDER_HH
11#define _LOG4SHIB_REMOTESYSLOGAPPENDER_HH
12
13#include <log4shib/Portability.hh>
14#include <string>
15#include <stdarg.h>
16#include <log4shib/LayoutAppender.hh>
17#include <log4shib/Priority.hh>
18#ifdef WIN32
19#include <winsock2.h>
20#else
21#include <netinet/in.h>
22#endif
23
24#ifdef LOG4SHIB_HAVE_SYSLOG
25#include <syslog.h>
26#else
28 typedef enum {
29 LOG_EMERG = 0,
30 LOG_ALERT = 1,
31 LOG_CRIT = 2,
32 LOG_ERR = 3,
33 LOG_WARNING = 4,
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),
62} SyslogFacility;
63#endif
64
65 namespace log4shib {
66
72 class LOG4SHIB_EXPORT RemoteSyslogAppender : public LayoutAppender {
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;
126 int _facility;
127 int _portNumber;
128 int _socket;
129 in_addr_t _ipAddr;
130 private:
131#ifdef WIN32
132 int _cludge;
133#endif
134 };
135}
136
137#endif // _LOG4SHIB_REMOTESYSLOGAPPENDER_HH
LOG4SHIB_EXPORT
#define LOG4SHIB_EXPORT
Definition: Export.hh:11
LayoutAppender.hh
Portability.hh
Priority.hh
SyslogFacility
SyslogFacility
Definition: RemoteSyslogAppender.hh:39
LOG_SYSLOG
@ LOG_SYSLOG
messages generated internally by syslogd
Definition: RemoteSyslogAppender.hh:45
LOG_LOCAL0
@ LOG_LOCAL0
reserved for local use
Definition: RemoteSyslogAppender.hh:54
LOG_UUCP
@ LOG_UUCP
UUCP subsystem.
Definition: RemoteSyslogAppender.hh:48
LOG_LOCAL4
@ LOG_LOCAL4
reserved for local use
Definition: RemoteSyslogAppender.hh:58
LOG_LOCAL5
@ LOG_LOCAL5
reserved for local use
Definition: RemoteSyslogAppender.hh:59
LOG_LPR
@ LOG_LPR
line printer subsystem
Definition: RemoteSyslogAppender.hh:46
LOG_LOCAL3
@ LOG_LOCAL3
reserved for local use
Definition: RemoteSyslogAppender.hh:57
LOG_DAEMON
@ LOG_DAEMON
system daemons
Definition: RemoteSyslogAppender.hh:43
LOG_LOCAL1
@ LOG_LOCAL1
reserved for local use
Definition: RemoteSyslogAppender.hh:55
LOG_FTP
@ LOG_FTP
ftp daemon
Definition: RemoteSyslogAppender.hh:51
LOG_USER
@ LOG_USER
random user-level messages
Definition: RemoteSyslogAppender.hh:41
LOG_AUTH
@ LOG_AUTH
security/authorization messages
Definition: RemoteSyslogAppender.hh:44
LOG_CRON
@ LOG_CRON
clock daemon
Definition: RemoteSyslogAppender.hh:49
LOG_MAIL
@ LOG_MAIL
mail system
Definition: RemoteSyslogAppender.hh:42
LOG_LOCAL6
@ LOG_LOCAL6
reserved for local use
Definition: RemoteSyslogAppender.hh:60
LOG_KERN
@ LOG_KERN
kernel messages
Definition: RemoteSyslogAppender.hh:40
LOG_AUTHPRIV
@ LOG_AUTHPRIV
security/authorization messages (private)
Definition: RemoteSyslogAppender.hh:50
LOG_NEWS
@ LOG_NEWS
network news subsystem
Definition: RemoteSyslogAppender.hh:47
LOG_LOCAL2
@ LOG_LOCAL2
reserved for local use
Definition: RemoteSyslogAppender.hh:56
LOG_LOCAL7
@ LOG_LOCAL7
reserved for local use
Definition: RemoteSyslogAppender.hh:61
SyslogLevel
SyslogLevel
from syslog.h
Definition: RemoteSyslogAppender.hh:28
LOG_ERR
@ LOG_ERR
error conditions
Definition: RemoteSyslogAppender.hh:32
LOG_CRIT
@ LOG_CRIT
critical conditions
Definition: RemoteSyslogAppender.hh:31
LOG_INFO
@ LOG_INFO
informational
Definition: RemoteSyslogAppender.hh:35
LOG_ALERT
@ LOG_ALERT
action must be taken immediately
Definition: RemoteSyslogAppender.hh:30
LOG_WARNING
@ LOG_WARNING
warning conditions
Definition: RemoteSyslogAppender.hh:33
LOG_DEBUG
@ LOG_DEBUG
debug-level messages
Definition: RemoteSyslogAppender.hh:36
LOG_NOTICE
@ LOG_NOTICE
normal but significant condition
Definition: RemoteSyslogAppender.hh:34
LOG_EMERG
@ LOG_EMERG
system is unusable
Definition: RemoteSyslogAppender.hh:29
log4shib::LayoutAppender
LayoutAppender is a common superclass for all Appenders that require a Layout.
Definition: LayoutAppender.hh:24
log4shib::Priority::Value
int Value
The type of Priority Values.
Definition: Priority.hh:84
log4shib::RemoteSyslogAppender
RemoteSyslogAppender sends LoggingEvents to a remote syslog system.
Definition: RemoteSyslogAppender.hh:72
log4shib::RemoteSyslogAppender::_portNumber
int _portNumber
Definition: RemoteSyslogAppender.hh:127
log4shib::RemoteSyslogAppender::_socket
int _socket
Definition: RemoteSyslogAppender.hh:128
log4shib::RemoteSyslogAppender::_relayer
const std::string _relayer
Definition: RemoteSyslogAppender.hh:125
log4shib::RemoteSyslogAppender::_facility
int _facility
Definition: RemoteSyslogAppender.hh:126
log4shib::RemoteSyslogAppender::_ipAddr
in_addr_t _ipAddr
Definition: RemoteSyslogAppender.hh:129
log4shib::RemoteSyslogAppender::_syslogName
const std::string _syslogName
Definition: RemoteSyslogAppender.hh:124
log4shib
The top level namespace for all 'Log for C++' types and classes.
Definition: AbortAppender.hh:16
log4shib::LoggingEvent
The internal representation of logging events.
Definition: LoggingEvent.hh:32