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