LDMX Software
Public Member Functions | Private Attributes | List of all members
framework::logging::Filter Class Reference

Our filter implementation aligning with Boost.Log. More...

Public Member Functions

 Filter (level fallback, std::unordered_map< std::string, level > custom)
 
 Filter (level fallback)
 
bool operator() (log::attribute_value_set const &attrs)
 

Private Attributes

level fallback_level_
 
std::unordered_map< std::string, level > custom_levels_
 

Detailed Description

Our filter implementation aligning with Boost.Log.

We store a default "fallback" level that is applied to all channels that do not exist within the custom mapping. If a channel does exist within the custom mapping, that value is used instead of the default value.

Definition at line 56 of file Logger.cxx.

Constructor & Destructor Documentation

◆ Filter() [1/2]

framework::logging::Filter::Filter ( level  fallback,
std::unordered_map< std::string, level >  custom 
)
inline

Definition at line 61 of file Logger.cxx.

62 : fallback_level_{fallback}, custom_levels_{custom} {}

◆ Filter() [2/2]

framework::logging::Filter::Filter ( level  fallback)
inline

Definition at line 63 of file Logger.cxx.

63: Filter(fallback, {}) {}

Member Function Documentation

◆ operator()()

bool framework::logging::Filter::operator() ( log::attribute_value_set const &  attrs)
inline

Definition at line 64 of file Logger.cxx.

64 {
65 const std::string& channel{safe_extract<std::string>(attrs["Channel"])};
66 const level& msg_level{safe_extract<level>(attrs["Severity"])};
67 auto it = custom_levels_.find(channel);
68 if (it != custom_levels_.end()) {
69 return msg_level >= it->second;
70 }
71 return msg_level >= fallback_level_;
72 }

Member Data Documentation

◆ custom_levels_

std::unordered_map<std::string, level> framework::logging::Filter::custom_levels_
private

Definition at line 58 of file Logger.cxx.

◆ fallback_level_

level framework::logging::Filter::fallback_level_
private

Definition at line 57 of file Logger.cxx.


The documentation for this class was generated from the following file: