CppLogging  1.0.4.0
C++ Logging Library
switch_filter.h
Go to the documentation of this file.
1 
9 #ifndef CPPLOGGING_FILTERS_SWITCH_FILTER_H
10 #define CPPLOGGING_FILTERS_SWITCH_FILTER_H
11 
12 #include "logging/filter.h"
13 
14 #include <atomic>
15 
16 namespace CppLogging {
17 
19 
24 class SwitchFilter : public Filter
25 {
26 public:
28 
31  explicit SwitchFilter(bool enabled) { Update(enabled); }
32  SwitchFilter(const SwitchFilter&) = delete;
34  virtual ~SwitchFilter() = default;
35 
36  SwitchFilter& operator=(const SwitchFilter&) = delete;
38 
40  bool enabled() const noexcept { return _enabled; }
41 
43 
46  void Update(bool enabled);
47 
48  // Implementation of Filter
49  bool FilterRecord(Record& record) override;
50 
51 private:
52  std::atomic<bool> _enabled;
53 };
54 
55 } // namespace CppLogging
56 
57 #endif // CPPLOGGING_FILTERS_SWITCH_FILTER_H
Logging filter interface.
Definition: filter.h:29
Logging record.
Definition: record.h:37
void Update(bool enabled)
Update switch filter with a given enabled flag.
SwitchFilter(SwitchFilter &&)=delete
virtual ~SwitchFilter()=default
SwitchFilter & operator=(const SwitchFilter &)=delete
SwitchFilter(bool enabled)
Initialize switch filter with a given enabled flag.
Definition: switch_filter.h:31
bool enabled() const noexcept
Get the filter enabled flag.
Definition: switch_filter.h:40
SwitchFilter(const SwitchFilter &)=delete
bool FilterRecord(Record &record) override
Filter the given logging record.
SwitchFilter & operator=(SwitchFilter &&)=delete
Logging filter interface definition.
C++ Logging project definitions.
Definition: appender.h:15