Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
kcenon::logger::level_filter Class Reference

Filter logs by minimum level. More...

#include <log_filter.h>

Inheritance diagram for kcenon::logger::level_filter:
Inheritance graph
Collaboration diagram for kcenon::logger::level_filter:
Collaboration graph

Public Member Functions

 level_filter (log_level min_level)
 
bool should_log (log_level level, const std::string &message, const std::string &file, int line, const std::string &function) const override
 Check if a log entry should be processed (legacy API)
 
void set_min_level (log_level level)
 
std::string get_name () const override
 Get the name of this filter.
 
- Public Member Functions inherited from kcenon::logger::log_filter
virtual ~log_filter ()=default
 
virtual bool should_log (const log_entry &entry) const override
 Check if a log entry should be processed (new interface)
 
- Public Member Functions inherited from kcenon::logger::log_filter_interface
virtual ~log_filter_interface ()=default
 

Private Attributes

log_level min_level_
 

Detailed Description

Filter logs by minimum level.

Definition at line 72 of file log_filter.h.

Constructor & Destructor Documentation

◆ level_filter()

kcenon::logger::level_filter::level_filter ( log_level min_level)
inlineexplicit

Definition at line 74 of file log_filter.h.

75 : min_level_(min_level) {}

Member Function Documentation

◆ get_name()

std::string kcenon::logger::level_filter::get_name ( ) const
inlineoverridevirtual

Get the name of this filter.

Returns
Filter name for identification

Reimplemented from kcenon::logger::log_filter.

Definition at line 93 of file log_filter.h.

93 {
94 return "level_filter";
95 }

◆ set_min_level()

void kcenon::logger::level_filter::set_min_level ( log_level level)
inline

Definition at line 89 of file log_filter.h.

89 {
90 min_level_ = level;
91 }

References min_level_.

◆ should_log()

bool kcenon::logger::level_filter::should_log ( log_level level,
const std::string & message,
const std::string & file,
int line,
const std::string & function ) const
inlineoverridevirtual

Check if a log entry should be processed (legacy API)

Parameters
levelLog level
messageLog message
fileSource file
lineSource line
functionFunction name
Returns
true if the log should be processed

Implements kcenon::logger::log_filter.

Definition at line 77 of file log_filter.h.

81 {
82 (void)message;
83 (void)file;
84 (void)line;
85 (void)function;
86 return static_cast<int>(level) >= static_cast<int>(min_level_);
87 }

References min_level_.

Member Data Documentation

◆ min_level_

log_level level_filter::min_level_
private

Definition at line 98 of file log_filter.h.

Referenced by set_min_level(), should_log(), and level_filter::should_log().


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