source: pacpusframework/trunk/3rd/apache-log4cxx/include/log4cxx/net/syslogappender.h@ 184

Last change on this file since 184 was 89, checked in by morasjul, 12 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 6.3 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_NET_SYSLOG_APPENDER_H
19#define _LOG4CXX_NET_SYSLOG_APPENDER_H
20
21#include <log4cxx/appenderskeleton.h>
22#include <log4cxx/helpers/syslogwriter.h>
23
24namespace log4cxx
25{
26 namespace net
27 {
28 /** Use SyslogAppender to send log messages to a remote syslog daemon.*/
29 class LOG4CXX_EXPORT SyslogAppender : public AppenderSkeleton
30 {
31 public:
32 DECLARE_LOG4CXX_OBJECT(SyslogAppender)
33 BEGIN_LOG4CXX_CAST_MAP()
34 LOG4CXX_CAST_ENTRY(SyslogAppender)
35 LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
36 END_LOG4CXX_CAST_MAP()
37
38
39
40 SyslogAppender();
41 SyslogAppender(const LayoutPtr& layout, int syslogFacility);
42 SyslogAppender(const LayoutPtr& layout,
43 const LogString& syslogHost, int syslogFacility);
44 ~SyslogAppender();
45 /** Release any resources held by this SyslogAppender.*/
46 void close();
47
48 /**
49 Returns the specified syslog facility as a lower-case String,
50 e.g. "kern", "user", etc.
51 */
52 static LogString getFacilityString(int syslogFacility);
53
54 /**
55 Returns the integer value corresponding to the named syslog
56 facility, or -1 if it couldn't be recognized.
57 @param facilityName one of the strings KERN, USER, MAIL, DAEMON,
58 AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0,
59 LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
60 The matching is case-insensitive.
61 */
62 static int getFacility(const LogString &facilityName);
63
64 void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
65
66 /**
67 This method returns immediately as options are activated when they
68 are set.
69 */
70 void activateOptions(log4cxx::helpers::Pool& p);
71 void setOption(const LogString& option, const LogString& value);
72
73 /**
74 The SyslogAppender requires a layout. Hence, this method returns
75 <code>true</code>.
76 */
77 virtual bool requiresLayout() const
78 { return true; }
79
80 /**
81 The <b>SyslogHost</b> option is the name of the the syslog host
82 where log output should go.
83 <b>WARNING</b> If the SyslogHost is not set, then this appender
84 will fail.
85 */
86 void setSyslogHost(const LogString& syslogHost);
87
88 /**
89 Returns the value of the <b>SyslogHost</b> option.
90 */
91 inline const LogString& getSyslogHost() const
92 { return syslogHost; }
93
94 /**
95 Set the syslog facility. This is the <b>Facility</b> option.
96
97 <p>The <code>facilityName</code> parameter must be one of the
98 strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP,
99 CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4,
100 LOCAL5, LOCAL6, LOCAL7. Case is unimportant.
101 */
102 void setFacility(const LogString& facilityName);
103
104 /**
105 Returns the value of the <b>Facility</b> option.
106 */
107 inline LogString getFacility() const
108 { return getFacilityString(syslogFacility); }
109
110 /**
111 If the <b>FacilityPrinting</b> option is set to true, the printed
112 message will include the facility name of the application. It is
113 <em>false</em> by default.
114 */
115 inline void setFacilityPrinting(bool facilityPrinting1)
116 { this->facilityPrinting = facilityPrinting1; }
117
118 /**
119 Returns the value of the <b>FacilityPrinting</b> option.
120 */
121 inline bool getFacilityPrinting() const
122 { return facilityPrinting; }
123
124 protected:
125 void initSyslogFacilityStr();
126
127 int syslogFacility; // Have LOG_USER as default
128 LogString facilityStr;
129 bool facilityPrinting;
130 helpers::SyslogWriter * sw;
131 LogString syslogHost;
132 private:
133 SyslogAppender(const SyslogAppender&);
134 SyslogAppender& operator=(const SyslogAppender&);
135 }; // class SyslogAppender
136 LOG4CXX_PTR_DEF(SyslogAppender);
137 } // namespace net
138} // namespace log4cxx
139
140#endif // _LOG4CXX_NET_SYSLOG_APPENDER_H
141
Note: See TracBrowser for help on using the repository browser.