ImFusion SDK 4.3
Sink Class Referenceabstract

#include <ImFusion/Core/Log/Sink.h>

Interface for a logger sink that can receive individual log events. More...

+ Inheritance diagram for Sink:

Detailed Description

Interface for a logger sink that can receive individual log events.

Classes

struct  Filter
 Structure storing a filter. More...
 
struct  LogCapture
 Structure storing a single log event. More...
 

Public Member Functions

void log (const LogCapture &capture)
 Logs the given message.
 
virtual void flush ()=0
 Ensure that all log captures are fully committed/written.
 
bool isAccepted (Level level, const char *category) noexcept
 Checks whether a log message of given level and category is accepted (i.e.
 
void addWhitelistFilter (Log::Level minLevel, const std::string &category)
 Adds a whitelist filter for this logger: both conditions of the filter must be met to accept a message.
 
void addBlacklistFilter (Log::Level maxLevel, const std::string &category)
 Adds a blacklist filter for this logger: both conditions of the filter must be met to reject a message.
 
const std::vector< Filter > & whitelistFilters () const
 Return the set of whitelist filters.
 
const std::vector< Filter > & blacklistFilters () const
 Return the set of blacklist filters.
 
void removeFilters (const std::string &category)
 Removes all filters matching category.
 
void clearFilters ()
 Clear all filters.
 
bool isEnabled () const
 Returns the flag whether this logger is enabled.
 
void setEnabled (bool value)
 Sets the flag whether this logger is enabled.
 

Protected Member Functions

virtual void logImpl (const LogCapture &capture)=0
 Performs the actual logging of the given message.
 

Member Function Documentation

◆ log()

void log ( const LogCapture & capture)

Logs the given message.

Calls logImpl() if the message passes all registered filters.

Parameters
captureLog capture

◆ flush()

virtual void flush ( )
pure virtual

Ensure that all log captures are fully committed/written.

Implemented in ConsoleSink, FileSink, and QDebugAppender.

◆ isAccepted()

bool isAccepted ( Level level,
const char * category )
noexcept

Checks whether a log message of given level and category is accepted (i.e.

consumed) by this Sink. A message is accepted in case it does not match any blacklist filter or if it matches at least one whitelist filter. If there are no filters defined all messages are accepted.

◆ addWhitelistFilter()

void addWhitelistFilter ( Log::Level minLevel,
const std::string & category )

Adds a whitelist filter for this logger: both conditions of the filter must be met to accept a message.

In case of multiple whitelist filters, messages matching at least one filter will be logged, even if they also match a blacklist filter. If there are no filters defined, all messages are accepted.

Parameters
minLevelMinimum log level, messages of this level or higher will be logged.
categoryCategory filter, messages where the category contains category will be logged. Leave empty to accept all categories.

◆ addBlacklistFilter()

void addBlacklistFilter ( Log::Level maxLevel,
const std::string & category )

Adds a blacklist filter for this logger: both conditions of the filter must be met to reject a message.

Only messages matching a whitelist filter or not matching any blacklist filter will be logged (i.e. whitelist filters take precedence over blacklist filters). If there are no filters defined all messages are accepted.

Parameters
maxLevelMaximum log level, messages of this level or lower will not be logged.
categoryCategory filter, messages where the category contains category will not be logged. Leave empty to reject all categories.

◆ logImpl()

virtual void logImpl ( const LogCapture & capture)
protectedpure virtual

Performs the actual logging of the given message.

Called by log() after filtering.

Parameters
captureLog capture

Implemented in ConsoleSink, FileSink, and QDebugAppender.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close