log4cplus 2.1.2
syslogappender.h
Go to the documentation of this file.
1// -*- C++ -*-
2// Module: Log4CPLUS
3// File: syslogappender.h
4// Created: 6/2001
5// Author: Tad E. Smith
6//
7//
8// Copyright 2001-2017 Tad E. Smith
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21
23
24#ifndef LOG4CPLUS_SYSLOG_APPENDER_HEADER_
25#define LOG4CPLUS_SYSLOG_APPENDER_HEADER_
26
27#include <log4cplus/config.hxx>
28
29#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
30#pragma once
31#endif
32
33#include <log4cplus/appender.h>
36
37
38namespace log4cplus
39{
40
85 : public Appender
86#if ! defined (LOG4CPLUS_SINGLE_THREADED)
87 , protected virtual helpers::IConnectorThreadClient
88#endif
89 {
90 public:
97
98 // Ctors
99#if defined (LOG4CPLUS_HAVE_SYSLOG_H)
101#endif
103 int port = 514, const tstring & facility = tstring (),
106 int port, const tstring & facility,
107 RemoteSyslogType remoteSyslogType, bool ipv6, bool fqdn);
109
110 // Dtor
112
113 // Methods
114 virtual void close();
115
116 protected:
117 virtual int getSysLogLevel(const LogLevel& ll) const;
118 virtual void append(const spi::InternalLoggingEvent& event);
119#if defined (LOG4CPLUS_HAVE_SYSLOG_H)
122#endif
125
126 // Data
129
130 typedef void (SysLogAppender:: * AppendFuncType) (
133
135 int port;
139 bool ipv6 = false;
140
142
144 void openSocket ();
145
146#if ! defined (LOG4CPLUS_SINGLE_THREADED)
147 virtual thread::Mutex const & ctcGetAccessMutex () const;
150 virtual void ctcSetConnected ();
151
153#endif
154
155 private:
156 // Disallow copying of instances of this class
158 SysLogAppender& operator=(const SysLogAppender&);
159
160 std::string identStr;
161 tstring hostname;
162 };
163
164} // end namespace log4cplus
165
166
167#endif // LOG4CPLUS_SYSLOG_APPENDER_HEADER_
virtual void ctcSetConnected()
Sets connected flag to true in ConnectorThread's client.
SysLogAppender(const log4cplus::helpers::Properties &properties)
RemoteSyslogType
Remote syslog IP protocol type.
void appendLocal(const spi::InternalLoggingEvent &event)
Local syslog (served by syslog()) worker function.
void appendRemote(const spi::InternalLoggingEvent &event)
Remote syslog worker function.
virtual int getSysLogLevel(const LogLevel &ll) const
SysLogAppender(const tstring &ident)
SysLogAppender(const tstring &ident, const tstring &host, int port=514, const tstring &facility=tstring(), RemoteSyslogType remoteSyslogType=RSTUdp, bool ipv6=false)
virtual helpers::Socket ctcConnect()
static tstring const remoteTimeFormat
void(SysLogAppender::* AppendFuncType)(const spi::InternalLoggingEvent &)
RemoteSyslogType remoteSyslogType
virtual void close()
Release any resources allocated within the appender such as file handles, network connections,...
virtual void append(const spi::InternalLoggingEvent &event)
Subclasses of Appender should implement this method to perform actual logging.
SysLogAppender(const tstring &ident, const tstring &host, int port, const tstring &facility, RemoteSyslogType remoteSyslogType, bool ipv6, bool fqdn)
virtual thread::Mutex const & ctcGetAccessMutex() const
virtual helpers::Socket & ctcGetSocket()
helpers::SharedObjectPtr< helpers::ConnectorThread > connector
Interface implemented by users of ConnectorThread.
This class implements client sockets (also called just "sockets").
The internal representation of logging events.
std::basic_string< tchar > tstring
Definition tstring.h:39
int LogLevel
Defines the minimum set of priorities recognized by the system, that is FATAL_LOG_LEVEL,...
Definition loglevel.h:48
#define LOG4CPLUS_EXPORT
Definition win32.h:141