CppLogging  1.0.4.0
C++ Logging Library
level_filter.cpp
Go to the documentation of this file.
1 
10 
11 namespace CppLogging {
12 
13 void LevelFilter::Update(Level level, bool positive)
14 {
15  _positive = positive;
16  _from = Level::NONE;
17  _to = level;
18 }
19 
20 void LevelFilter::Update(Level from, Level to, bool positive)
21 {
22  _positive = positive;
23  if (from <= to)
24  {
25  _from = from;
26  _to = to;
27  }
28  else
29  {
30  _from = to;
31  _to = from;
32  }
33 }
34 
36 {
37  if (_positive)
38  return ((record.level >= _from) && (record.level <= _to));
39  else
40  return ((record.level < _from) || (record.level > _to));
41 }
42 
43 } // namespace CppLogging
Level from() const noexcept
Get Level from value.
Definition: level_filter.h:52
Level to() const noexcept
Get Level to value.
Definition: level_filter.h:54
bool positive() const noexcept
Get the positive filtration flag.
Definition: level_filter.h:49
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.
Logging record.
Definition: record.h:37
Level level
Level of the logging record.
Definition: record.h:44
Level filter definition.
C++ Logging project definitions.
Definition: appender.h:15
Level
Logging level.
Definition: level.h:18
@ NONE
Log nothing.