# filter.h

Go to the documentation of this file.

    00001 // Module:  Log4CPLUS
    00002 // File:    filter.h
    00003 // Created: 5/2003
    00004 // Author:  Tad E. Smith
    00005 //
    00006 //
    00007 // Copyright (C) Tad E. Smith  All rights reserved.
    00008 //
    00009 // This software is published under the terms of the Apache Software
    00010 // License version 1.1, a copy of which has been included with this
    00011 // distribution in the LICENSE.APL file.
    00012 //
    00013
    00017 #ifndef LOG4CPLUS_SPI_FILTER_HEADER_
    00018 #define LOG4CPLUS_SPI_FILTER_HEADER_
    00019
    00020 #include <log4cplus/config.h>
    00021 #include <log4cplus/helpers/pointer.h>
    00022 #include <log4cplus/helpers/property.h>
    00023 #include <log4cplus/spi/loggingevent.h>
    00024
    00025
    00026 namespace log4cplus {
    00027     namespace spi {
    00028
    00029
    00030         enum FilterResult { DENY,
    00033                             NEUTRAL,
    00037                             ACCEPT
    00040                           };
    00041
    00042         // Forward Declarations
    00043         class Filter;
    00044
    00045
    00051         LOG4CPLUS_EXPORT FilterResult checkFilter(const Filter* filter,
    00052                                                   const InternalLoggingEvent& event);
    00053
    00054         typedef helpers::SharedObjectPtr<Filter> FilterPtr;
    00055
    00056
    00084         class LOG4CPLUS_EXPORT Filter : public log4cplus::helpers::SharedObject {
    00085         public:
    00086           // ctor and dtor
    00087             Filter();
    00088             virtual ~Filter();
    00089
    00090           // Methods
    00094             void appendFilter(FilterPtr filter);
    00095
    00106             virtual FilterResult decide(const InternalLoggingEvent& event) const = 0;
    00107
    00108           // Data
    00112             FilterPtr next;
    00113         };
    00114
    00115
    00116
    00125         class LOG4CPLUS_EXPORT DenyAllFilter : public Filter {
    00126         public:
    00131             virtual FilterResult decide(const InternalLoggingEvent& event) const;
    00132         };
    00133
    00134
    00146         class LOG4CPLUS_EXPORT LogLevelMatchFilter : public Filter {
    00147         public:
    00148             LogLevelMatchFilter();
    00149             LogLevelMatchFilter(const log4cplus::helpers::Properties& p);
    00150
    00161             virtual FilterResult decide(const InternalLoggingEvent& event) const;
    00162
    00163         private:
    00164           // Methods
    00165             void init();
    00166
    00167           // Data
    00169             bool acceptOnMatch;
    00170             LogLevel logLevelToMatch;
    00171         };
    00172
    00173
    00174
    00200         class LOG4CPLUS_EXPORT LogLevelRangeFilter : public Filter {
    00201         public:
    00202           // ctors
    00203             LogLevelRangeFilter();
    00204             LogLevelRangeFilter(const log4cplus::helpers::Properties& p);
    00205
    00209             virtual FilterResult decide(const InternalLoggingEvent& event) const;
    00210
    00211         private:
    00212           // Methods
    00213             void init();
    00214
    00215           // Data
    00217             bool acceptOnMatch;
    00218             LogLevel logLevelMin;
    00219             LogLevel logLevelMax;
    00220         };
    00221
    00222
    00223
    00235         class LOG4CPLUS_EXPORT StringMatchFilter : public Filter {
    00236         public:
    00237           // ctors
    00238             StringMatchFilter();
    00239             StringMatchFilter(const log4cplus::helpers::Properties& p);
    00240
    00244             virtual FilterResult decide(const InternalLoggingEvent& event) const;
    00245
    00246         private:
    00247           // Methods
    00248             void init();
    00249
    00250           // Data
    00252             bool acceptOnMatch;
    00253             log4cplus::tstring stringToMatch;
    00254         };
    00255
    00256     } // end namespace spi
    00257 } // end namespace log4cplus
    00258
    00259 #endif /* LOG4CPLUS_SPI_FILTER_HEADER_ */
    00260
    00261