Loading...
Searching...
No Matches
RemoteSyslogAppender.hh
Go to the documentation of this file.
/*
* SyslogAppender.hh
*
* Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
* Copyright 2001, Walter Stroebel. All rights reserved.
*
* See the COPYING file for the terms of usage and distribution.
*/
#ifndef _LOG4SHIB_REMOTESYSLOGAPPENDER_HH
#define _LOG4SHIB_REMOTESYSLOGAPPENDER_HH
#include <log4shib/Portability.hh>
#include <string>
#include <stdarg.h>
#include <log4shib/LayoutAppender.hh>
#include <log4shib/Priority.hh>
#ifdef WIN32
#include <winsock2.h>
#else
#include <netinet/in.h>
#endif
#ifdef LOG4SHIB_HAVE_SYSLOG
#include <syslog.h>
#else
typedef enum {
LOG_EMERG = 0,
LOG_ALERT = 1,
LOG_CRIT = 2,
LOG_ERR = 3,
LOG_WARNING = 4,
LOG_NOTICE = 5,
LOG_INFO = 6,
LOG_DEBUG = 7,
} SyslogLevel;
typedef enum {
LOG_KERN = (0<<3),
LOG_USER = (1<<3),
LOG_MAIL = (2<<3),
LOG_DAEMON = (3<<3),
LOG_AUTH = (4<<3),
LOG_SYSLOG = (5<<3),
LOG_LPR = (6<<3),
LOG_NEWS = (7<<3),
LOG_UUCP = (8<<3),
LOG_CRON = (9<<3),
LOG_AUTHPRIV = (10<<3),
LOG_FTP = (11<<3),
/* other codes through 15 reserved for system use */
LOG_LOCAL0 = (16<<3),
LOG_LOCAL1 = (17<<3),
LOG_LOCAL2 = (18<<3),
LOG_LOCAL3 = (19<<3),
LOG_LOCAL4 = (20<<3),
LOG_LOCAL5 = (21<<3),
LOG_LOCAL6 = (22<<3),
LOG_LOCAL7 = (23<<3),
} SyslogFacility;
#endif
namespace log4shib {
class LOG4SHIB_EXPORT RemoteSyslogAppender : public LayoutAppender {
public:
static int toSyslogPriority(Priority::Value priority);
RemoteSyslogAppender(const std::string& name,
const std::string& syslogName,
const std::string& relayer,
int facility = LOG_USER,
int portNumber = 514);
virtual ~RemoteSyslogAppender();
virtual bool reopen();
virtual void close();
protected:
virtual void open();
virtual void _append(const LoggingEvent& event);
const std::string _syslogName;
const std::string _relayer;
int _facility;
int _portNumber;
int _socket;
in_addr_t _ipAddr;
private:
#ifdef WIN32
int _cludge;
#endif
};
}
#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
LayoutAppender(const std::string &name)
Definition LayoutAppender.cpp:15
log4shib::Priority::Value
int Value
The type of Priority Values.
Definition Priority.hh:84
log4shib::RemoteSyslogAppender::close
virtual void close()
Closes the socket.
Definition RemoteSyslogAppender.cpp:120
log4shib::RemoteSyslogAppender::_append
virtual void _append(const LoggingEvent &event)
Sends a LoggingEvent to the remote syslog.
Definition RemoteSyslogAppender.cpp:131
log4shib::RemoteSyslogAppender::_portNumber
int _portNumber
Definition RemoteSyslogAppender.hh:127
log4shib::RemoteSyslogAppender::reopen
virtual bool reopen()
Closes and reopens the socket.
Definition RemoteSyslogAppender.cpp:172
log4shib::RemoteSyslogAppender::toSyslogPriority
static int toSyslogPriority(Priority::Value priority)
Translates a log4shib priority to a syslog priority.
Definition RemoteSyslogAppender.cpp:37
log4shib::RemoteSyslogAppender::RemoteSyslogAppender
RemoteSyslogAppender(const std::string &name, const std::string &syslogName, const std::string &relayer, int facility=LOG_USER, int portNumber=514)
Instantiate a RemoteSyslogAppender with given name and name and facility for syslog.
Definition RemoteSyslogAppender.cpp:58
log4shib::RemoteSyslogAppender::open
virtual void open()
Just creates the socket.
Definition RemoteSyslogAppender.cpp:87
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