CppLogging  1.0.4.0
C++ Logging Library
logger_filter.h
Go to the documentation of this file.
1 
9 #ifndef CPPLOGGING_FILTERS_LOGGER_FILTER_H
10 #define CPPLOGGING_FILTERS_LOGGER_FILTER_H
11 
12 #include "logging/filter.h"
13 
14 #include <atomic>
15 #include <string>
16 
17 namespace CppLogging {
18 
20 
26 class LoggerFilter : public Filter
27 {
28 public:
30 
34  explicit LoggerFilter(const std::string& pattern, bool positive = true) : _positive(positive), _pattern(pattern) {}
35  LoggerFilter(const LoggerFilter&) = delete;
37  virtual ~LoggerFilter() = default;
38 
39  LoggerFilter& operator=(const LoggerFilter&) = delete;
41 
43  bool positive() const noexcept { return _positive; }
44 
46  const std::string& pattern() const noexcept { return _pattern; }
47 
48  // Implementation of Filter
49  bool FilterRecord(Record& record) override;
50 
51 private:
52  std::atomic<bool> _positive;
53  std::string _pattern;
54 };
55 
56 } // namespace CppLogging
57 
58 #endif // CPPLOGGING_FILTERS_LOGGER_FILTER_H
Logging filter interface.
Definition: filter.h:29
LoggerFilter & operator=(LoggerFilter &&)=delete
LoggerFilter(LoggerFilter &&)=delete
bool positive() const noexcept
Get the positive filtration flag.
Definition: logger_filter.h:43
const std::string & pattern() const noexcept
Get the logger pattern.
Definition: logger_filter.h:46
bool FilterRecord(Record &record) override
Filter the given logging record.
virtual ~LoggerFilter()=default
LoggerFilter & operator=(const LoggerFilter &)=delete
LoggerFilter(const std::string &pattern, bool positive=true)
Initialize logger filter with a given pattern.
Definition: logger_filter.h:34
LoggerFilter(const LoggerFilter &)=delete
Logging record.
Definition: record.h:37
Logging filter interface definition.
C++ Logging project definitions.
Definition: appender.h:15