source: XMLIO_V2/external/include/Poco/Net/RemoteSyslogChannel.h @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 6.4 KB
Line 
1//
2// RemoteSyslogChannel.h
3//
4// $Id: //poco/1.3/Net/include/Poco/Net/RemoteSyslogChannel.h#2 $
5//
6// Library: Net
7// Package: Logging
8// Module:  RemoteSyslogChannel
9//
10// Definition of the RemoteSyslogChannel class.
11//
12// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// Permission is hereby granted, free of charge, to any person or organization
16// obtaining a copy of the software and accompanying documentation covered by
17// this license (the "Software") to use, reproduce, display, distribute,
18// execute, and transmit the Software, and to prepare derivative works of the
19// Software, and to permit third-parties to whom the Software is furnished to
20// do so, all subject to the following:
21//
22// The copyright notices in the Software and this entire statement, including
23// the above license grant, this restriction and the following disclaimer,
24// must be included in all copies of the Software, in whole or in part, and
25// all derivative works of the Software, unless such copies or derivative
26// works are solely in the form of machine-executable object code generated by
27// a source language processor.
28//
29// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35// DEALINGS IN THE SOFTWARE.
36//
37
38
39#ifndef Net_RemoteSyslogChannel_INCLUDED
40#define Net_RemoteSyslogChannel_INCLUDED
41
42
43#include "Poco/Net/Net.h"
44#include "Poco/Channel.h"
45#include "Poco/Net/DatagramSocket.h"
46
47
48namespace Poco {
49namespace Net {
50
51
52class Net_API RemoteSyslogChannel: public Poco::Channel
53        /// This Channel implements remote syslog logging over UDP according
54        /// to the syslog Working Group Internet Draft:
55        /// "The syslog Protocol" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-protocol-17.txt>,
56        /// and "Transmission of syslog messages over UDP" <http://www.ietf.org/internet-drafts/draft-ietf-syslog-transport-udp-07.txt>.
57        ///
58        /// In addition, RemoteSyslogChannel also supports the "old" BSD syslog
59        /// protocol, as described in RFC 3164.
60{
61public:
62        static const std::string BSD_TIMEFORMAT;
63        static const std::string SYSLOG_TIMEFORMAT;
64
65        enum Severity
66        {
67                SYSLOG_EMERGENCY     = 0, /// Emergency: system is unusable
68                SYSLOG_ALERT         = 1, /// Alert: action must be taken immediately
69                SYSLOG_CRITICAL      = 2, /// Critical: critical conditions
70                SYSLOG_ERROR         = 3, /// Error: error conditions
71                SYSLOG_WARNING       = 4, /// Warning: warning conditions
72                SYSLOG_NOTICE        = 5, /// Notice: normal but significant condition
73                SYSLOG_INFORMATIONAL = 6, /// Informational: informational messages
74                SYSLOG_DEBUG         = 7  /// Debug: debug-level messages
75        };
76       
77        enum Facility
78        {
79                SYSLOG_KERN     = ( 0<<3), /// kernel messages
80                SYSLOG_USER     = ( 1<<3), /// random user-level messages
81                SYSLOG_MAIL     = ( 2<<3), /// mail system
82                SYSLOG_DAEMON   = ( 3<<3), /// system daemons
83                SYSLOG_AUTH     = ( 4<<3), /// security/authorization messages
84                SYSLOG_SYSLOG   = ( 5<<3), /// messages generated internally by syslogd
85                SYSLOG_LPR      = ( 6<<3), /// line printer subsystem
86                SYSLOG_NEWS     = ( 7<<3), /// network news subsystem
87                SYSLOG_UUCP     = ( 8<<3), /// UUCP subsystem
88                SYSLOG_CRON     = ( 9<<3), /// clock daemon
89                SYSLOG_AUTHPRIV = (10<<3), /// security/authorization messages (private)
90                SYSLOG_FTP      = (11<<3), /// ftp daemon
91                SYSLOG_NTP      = (12<<3), /// ntp subsystem
92                SYSLOG_LOGAUDIT = (13<<3), /// log audit
93                SYSLOG_LOGALERT = (14<<3), /// log alert
94                SYSLOG_CLOCK    = (15<<3), /// clock deamon
95                SYSLOG_LOCAL0   = (16<<3), /// reserved for local use
96                SYSLOG_LOCAL1   = (17<<3), /// reserved for local use
97                SYSLOG_LOCAL2   = (18<<3), /// reserved for local use
98                SYSLOG_LOCAL3   = (19<<3), /// reserved for local use
99                SYSLOG_LOCAL4   = (20<<3), /// reserved for local use
100                SYSLOG_LOCAL5   = (21<<3), /// reserved for local use
101                SYSLOG_LOCAL6   = (22<<3), /// reserved for local use
102                SYSLOG_LOCAL7   = (23<<3)  /// reserved for local use
103        };
104       
105        enum
106        {
107                SYSLOG_PORT = 514
108        };
109       
110        RemoteSyslogChannel();
111                /// Creates a RemoteSyslogChannel.
112               
113        RemoteSyslogChannel(const std::string& address, const std::string& name, int facility = SYSLOG_USER, bool bsdFormat = false);
114                /// Creates a RemoteSyslogChannel with the given target address, name, and facility.
115                /// If bsdFormat is true, messages are formatted according to RFC 3164.
116       
117        void open();
118                /// Opens the RemoteSyslogChannel.
119               
120        void close();
121                /// Closes the RemoteSyslogChannel.
122               
123        void log(const Message& msg);
124                /// Sends the message's text to the syslog service.
125               
126        void setProperty(const std::string& name, const std::string& value);
127                /// Sets the property with the given value.
128                ///
129                /// The following properties are supported:
130                ///     * name:      The name used to identify the source of log messages.
131                ///     * facility:  The facility added to each log message. See the Facility enumeration for a list of supported values.
132                ///                  The LOG_ prefix can be omitted and values are case insensitive (e.g. a facility value "mail" is recognized as SYSLOG_MAIL)
133                ///     * format:    "bsd" (RFC 3164 format) or "new" (default)
134                ///     * loghost:   The target IP address or host name where log messages are sent. Optionally, a port number (separated
135                ///                  by a colon) can also be specified.
136                ///     * host:      (optional) Host name included in syslog messages. If not specified, the host's real domain name or
137                ///                  IP address will be used.
138               
139        std::string getProperty(const std::string& name) const;
140                /// Returns the value of the property with the given name.
141
142        static void registerChannel();
143                /// Registers the channel with the global LoggingFactory.
144
145        static const std::string PROP_NAME;
146        static const std::string PROP_FACILITY;
147        static const std::string PROP_FORMAT;
148        static const std::string PROP_LOGHOST;
149        static const std::string PROP_HOST;
150
151protected:
152        ~RemoteSyslogChannel();
153        static int getPrio(const Message& msg);
154
155private:
156        std::string _logHost;
157        std::string _name;
158        std::string _host;
159        int  _facility;
160        bool _bsdFormat;
161        DatagramSocket _socket;
162        bool _open;
163};
164
165
166} } // namespace Poco::Net
167
168
169#endif // Net_RemoteSyslogChannel_INCLUDED
Note: See TracBrowser for help on using the repository browser.