CppLogging 1.0.5.0
C++ Logging Library
Loading...
Searching...
No Matches
level_filter.h
Go to the documentation of this file.
1
9#ifndef CPPLOGGING_FILTERS_LEVEL_FILTER_H
10#define CPPLOGGING_FILTERS_LEVEL_FILTER_H
11
12#include "logging/filter.h"
13
14#include <atomic>
15
16namespace CppLogging {
17
19
25class LevelFilter : public Filter
26{
27public:
29
33 explicit LevelFilter(Level level, bool positive = true) { Update(level, positive); }
35
40 explicit LevelFilter(Level from, Level to, bool positive = true) { Update(from, to, positive); }
41 LevelFilter(const LevelFilter&) = delete;
43 virtual ~LevelFilter() = default;
44
47
49 bool positive() const noexcept { return _positive; }
50
52 Level from() const noexcept { return _from; }
54 Level to() const noexcept { return _to; }
55
57
61 void Update(Level level, bool positive = true);
63
68 void Update(Level from, Level to, bool positive = true);
69
70 // Implementation of Filter
71 bool FilterRecord(Record& record) override;
72
73private:
74 std::atomic<bool> _positive;
75 std::atomic<Level> _from;
76 std::atomic<Level> _to;
77};
78
79} // namespace CppLogging
80
81#endif // CPPLOGGING_FILTERS_LEVEL_FILTER_H
Logging filter interface.
Definition filter.h:29
Level from() const noexcept
Get Level from value.
LevelFilter(Level from, Level to, bool positive=true)
Initialize level filter with a given level range.
Level to() const noexcept
Get Level to value.
LevelFilter(const LevelFilter &)=delete
virtual ~LevelFilter()=default
bool positive() const noexcept
Get the positive filtration flag.
LevelFilter & operator=(LevelFilter &&)=delete
LevelFilter & operator=(const LevelFilter &)=delete
bool FilterRecord(Record &record) override
Filter the given logging record.
void Update(Level level, bool positive=true)
Update level filter with a given level value.
LevelFilter(Level level, bool positive=true)
Initialize level filter with a given level value.
LevelFilter(LevelFilter &&)=delete
Logging record.
Definition record.h:37
Logging filter interface definition.
C++ Logging project definitions.
Definition appender.h:15
Level
Logging level.
Definition level.h:18