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

Base class for log filtering. More...

#include <log_filter.h>

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

Public Member Functions

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

Detailed Description

Base class for log filtering.

This class provides a compatibility layer between the old API and the new interface-based approach. It implements log_filter_interface.

Definition at line 27 of file log_filter.h.

Constructor & Destructor Documentation

◆ ~log_filter()

virtual kcenon::logger::log_filter::~log_filter ( )
virtualdefault

Member Function Documentation

◆ get_name()

virtual std::string kcenon::logger::log_filter::get_name ( ) const
inlineoverridevirtual

Get the name of this filter.

Returns
Filter name for identification

Implements kcenon::logger::log_filter_interface.

Reimplemented in kcenon::logger::composite_filter, kcenon::logger::function_filter, kcenon::logger::level_filter, and kcenon::logger::regex_filter.

Definition at line 63 of file log_filter.h.

63 {
64 return "base_filter";
65 }

◆ should_log() [1/2]

virtual bool kcenon::logger::log_filter::should_log ( const log_entry & entry) const
inlineoverridevirtual

Check if a log entry should be processed (new interface)

Parameters
entryThe log entry to check
Returns
true if the log should be processed

Implements kcenon::logger::log_filter_interface.

Definition at line 36 of file log_filter.h.

36 {
37 std::string file = entry.location ? entry.location->file.to_string() : "";
38 int line = entry.location ? entry.location->line : 0;
39 std::string function = entry.location ? entry.location->function.to_string() : "";
40
41 return should_log(entry.level, entry.message.to_string(), file, line, function);
42 }
virtual bool should_log(const log_entry &entry) const override
Check if a log entry should be processed (new interface)
Definition log_filter.h:36

References kcenon::logger::log_entry::level, kcenon::logger::log_entry::location, kcenon::logger::log_entry::message, should_log(), and kcenon::logger::small_string< SSO_SIZE >::to_string().

Referenced by should_log().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ should_log() [2/2]

virtual bool kcenon::logger::log_filter::should_log ( log_level level,
const std::string & message,
const std::string & file,
int line,
const std::string & function ) const
pure virtual

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

Implemented in kcenon::logger::composite_filter, kcenon::logger::function_filter, kcenon::logger::level_filter, and kcenon::logger::regex_filter.


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