~ubuntu-branches/ubuntu/gutsy/poco/gutsy

« back to all changes in this revision

Viewing changes to Foundation/include/Poco/SyslogChannel.h

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2007-04-27 18:33:48 UTC
  • Revision ID: james.westby@ubuntu.com-20070427183348-xgnpct0qd6a2ip34
Tags: upstream-1.2.9
ImportĀ upstreamĀ versionĀ 1.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// SyslogChannel.h
 
3
//
 
4
// $Id: //poco/1.2/Foundation/include/Poco/SyslogChannel.h#1 $
 
5
//
 
6
// Library: Foundation
 
7
// Package: Logging
 
8
// Module:  SyslogChannel
 
9
//
 
10
// Definition of the SyslogChannel class specific to UNIX.
 
11
//
 
12
// Copyright (c) 2004-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 Foundation_SyslogChannel_INCLUDED
 
40
#define Foundation_SyslogChannel_INCLUDED
 
41
 
 
42
 
 
43
#include "Poco/Foundation.h"
 
44
#include "Poco/Channel.h"
 
45
 
 
46
 
 
47
namespace Poco {
 
48
 
 
49
 
 
50
class Foundation_API SyslogChannel: public Channel
 
51
        /// This Unix-only channel works with the Unix syslog service.
 
52
{
 
53
public:
 
54
        enum Option
 
55
        {
 
56
                SYSLOG_PID    = 0x01, /// log the pid with each message
 
57
                SYSLOG_CONS   = 0x02, /// log on the console if errors in sending
 
58
                SYSLOG_NDELAY = 0x08, /// don't delay open
 
59
                SYSLOG_PERROR = 0x20  /// log to stderr as well (not supported on all platforms)
 
60
        };
 
61
        
 
62
        enum Facility
 
63
        {
 
64
                SYSLOG_KERN     = ( 0<<3), /// kernel messages
 
65
                SYSLOG_USER     = ( 1<<3), /// random user-level messages
 
66
                SYSLOG_MAIL     = ( 2<<3), /// mail system
 
67
                SYSLOG_DAEMON   = ( 3<<3), /// system daemons
 
68
                SYSLOG_AUTH     = ( 4<<3), /// security/authorization messages
 
69
                SYSLOG_SYSLOG   = ( 5<<3), /// messages generated internally by syslogd
 
70
                SYSLOG_LPR      = ( 6<<3), /// line printer subsystem
 
71
                SYSLOG_NEWS     = ( 7<<3), /// network news subsystem
 
72
                SYSLOG_UUCP     = ( 8<<3), /// UUCP subsystem
 
73
                SYSLOG_CRON     = ( 9<<3), /// clock daemon
 
74
                SYSLOG_AUTHPRIV = (10<<3), /// security/authorization messages (private)
 
75
                SYSLOG_FTP      = (11<<3), /// ftp daemon
 
76
                SYSLOG_LOCAL0   = (16<<3), /// reserved for local use
 
77
                SYSLOG_LOCAL1   = (17<<3), /// reserved for local use
 
78
                SYSLOG_LOCAL2   = (18<<3), /// reserved for local use
 
79
                SYSLOG_LOCAL3   = (19<<3), /// reserved for local use
 
80
                SYSLOG_LOCAL4   = (20<<3), /// reserved for local use
 
81
                SYSLOG_LOCAL5   = (21<<3), /// reserved for local use
 
82
                SYSLOG_LOCAL6   = (22<<3), /// reserved for local use
 
83
                SYSLOG_LOCAL7   = (23<<3)  /// reserved for local use
 
84
        };
 
85
        
 
86
        SyslogChannel();
 
87
                /// Creates a SyslogChannel.
 
88
                
 
89
        SyslogChannel(const std::string& name, int options = SYSLOG_CONS, int facility = SYSLOG_USER);
 
90
                /// Creates a SyslogChannel with the given name, options and facility.
 
91
        
 
92
        void open();
 
93
                /// Opens the SyslogChannel.
 
94
                
 
95
        void close();
 
96
                /// Closes the SyslogChannel.
 
97
                
 
98
        void log(const Message& msg);
 
99
                /// Sens the message's text to the syslog service.
 
100
                
 
101
        void setProperty(const std::string& name, const std::string& value);
 
102
                /// Sets the property with the given value.
 
103
                ///
 
104
                /// The following properties are supported:
 
105
                ///     * name:     The name used to identify the source of log messages.
 
106
                ///     * facility: The facility added to each log message. See the Facility enumeration for a list of supported values.
 
107
                ///     * options:  The logging options. See the Option enumeration for a list of supported values.
 
108
                
 
109
        std::string getProperty(const std::string& name) const;
 
110
                /// Returns the value of the property with the given name.
 
111
 
 
112
        static const std::string PROP_NAME;
 
113
        static const std::string PROP_FACILITY;
 
114
        static const std::string PROP_OPTIONS;
 
115
 
 
116
protected:
 
117
        ~SyslogChannel();
 
118
        static int getPrio(const Message& msg);
 
119
 
 
120
private:
 
121
        std::string _name;
 
122
        int  _options;
 
123
        int  _facility;
 
124
        bool _open;
 
125
};
 
126
 
 
127
 
 
128
} // namespace Poco
 
129
 
 
130
 
 
131
#endif // Foundation_SyslogChannel_INCLUDED