source: pacpusframework/branches/2.0-beta1/3rd/apache-log4cxx/include/log4cxx/filter/stringmatchfilter.h@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 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: 4.0 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_FILTER_STRING_MATCH_FILTER_H
19#define _LOG4CXX_FILTER_STRING_MATCH_FILTER_H
20
21#include <log4cxx/spi/filter.h>
22
23namespace log4cxx
24{
25 namespace filter
26 {
27 /**
28 This is a very simple filter based on string matching.
29
30 <p>The filter admits two options <b>StringToMatch</b> and
31 <b>AcceptOnMatch</b>. If there is a match between the value of the
32 StringToMatch option and the message of the {@link spi::LoggingEvent
33 LoggingEvent}, then the #decide method returns
34 {@link log4cxx::spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b> option
35 value is true, if it is false then {@link log4cxx::spi::Filter#DENY DENY} is
36 returned. If there is no match, {@link log4cxx::spi::Filter#NEUTRAL NEUTRAL}
37 is returned.
38
39 <p>See configuration files <a
40 href="../xml/doc-files/test6.xml">test6.xml</a>, <a
41 href="../xml/doc-files/test7.xml">test7.xml</a>, <a
42 href="../xml/doc-files/test8.xml">test8.xml</a>, <a
43 href="../xml/doc-files/test9.xml">test9.xml</a>, and <a
44 href="../xml/doc-files/test10.xml">test10.xml</a> for examples of
45 seeting up a <code>StringMatchFilter</code>.
46 */
47
48 class LOG4CXX_EXPORT StringMatchFilter : public spi::Filter
49 {
50 private:
51 bool acceptOnMatch;
52 LogString stringToMatch;
53
54 public:
55 typedef spi::Filter BASE_CLASS;
56 DECLARE_LOG4CXX_OBJECT(StringMatchFilter)
57 BEGIN_LOG4CXX_CAST_MAP()
58 LOG4CXX_CAST_ENTRY(StringMatchFilter)
59 LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
60 END_LOG4CXX_CAST_MAP()
61
62 StringMatchFilter();
63
64 /**
65 Set options
66 */
67 virtual void setOption(const LogString& option,
68 const LogString& value);
69
70 inline void setStringToMatch(const LogString& stringToMatch1)
71 { this->stringToMatch.assign(stringToMatch1); }
72
73 inline const LogString& getStringToMatch() const
74 { return stringToMatch; }
75
76 inline void setAcceptOnMatch(bool acceptOnMatch1)
77 { this->acceptOnMatch = acceptOnMatch1; }
78
79 inline bool getAcceptOnMatch() const
80 { return acceptOnMatch; }
81
82 /**
83 Returns {@link log4cxx::spi::Filter#NEUTRAL NEUTRAL}
84 is there is no string match.
85 */
86 FilterDecision decide(const spi::LoggingEventPtr& event) const;
87 }; // class StringMatchFilter
88 LOG4CXX_PTR_DEF(StringMatchFilter);
89 } // namespace filter
90} // namespace log4cxx
91
92#endif // _LOG4CXX_FILTER_STRING_MATCH_FILTER_H
Note: See TracBrowser for help on using the repository browser.