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

Custom filter that filters by message content. More...

Inheritance diagram for content_filter:
Inheritance graph
Collaboration diagram for content_filter:
Collaboration graph

Public Member Functions

 content_filter (std::string keyword)
 
bool should_log (const log_entry &entry) const override
 Check if a log entry should be processed.
 
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
 

Private Attributes

std::string keyword_
 

Detailed Description

Custom filter that filters by message content.

Examples
decorator_usage.cpp.

Definition at line 66 of file decorator_usage.cpp.

Constructor & Destructor Documentation

◆ content_filter()

content_filter::content_filter ( std::string keyword)
inlineexplicit
Examples
decorator_usage.cpp.

Definition at line 68 of file decorator_usage.cpp.

68: keyword_(std::move(keyword)) {}
std::string keyword_

Member Function Documentation

◆ get_name()

std::string content_filter::get_name ( ) const
inlineoverridevirtual

Get the name of this filter.

Returns
Filter name for identification

Implements kcenon::logger::log_filter_interface.

Examples
decorator_usage.cpp.

Definition at line 75 of file decorator_usage.cpp.

75 {
76 return "content_filter";
77 }

◆ should_log()

bool content_filter::should_log ( const log_entry & entry) const
inlineoverridevirtual

Check if a log entry should be processed.

Parameters
entryThe log entry to check
Returns
true if the entry should be logged, false otherwise

Implements kcenon::logger::log_filter_interface.

Examples
decorator_usage.cpp.

Definition at line 70 of file decorator_usage.cpp.

70 {
71 std::string msg(entry.message.data(), entry.message.size());
72 return msg.find(keyword_) != std::string::npos;
73 }
const char * data() const noexcept
Get data pointer.
size_t size() const noexcept
Get size.
small_string_256 message
The actual log message.
Definition log_entry.h:169

References kcenon::logger::small_string< SSO_SIZE >::data(), keyword_, kcenon::logger::log_entry::message, and kcenon::logger::small_string< SSO_SIZE >::size().

Here is the call graph for this function:

Member Data Documentation

◆ keyword_

std::string content_filter::keyword_
private
Examples
decorator_usage.cpp.

Definition at line 80 of file decorator_usage.cpp.

Referenced by should_log().


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