#include <ImFusion/Core/Log/Sink.h>
Interface for a logger sink that can receive individual log events.
More...
Interface for a logger sink that can receive individual log events.
|
| 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.
|
| bool | setDateTimeFormatFunction (const DateTimeFormatFunction &fcn) |
| | Set a callback function for formatting date and time.
|
|
std::string | defaultDateTimeFormatFunction (const std::chrono::system_clock::time_point &time) |
| | Get a string representing date and time.
|
|
| virtual void | logImpl (const LogCapture &capture)=0 |
| | Performs the actual logging of the given message.
|
◆ DateTimeFormatFunction
Signature of the callback function used by Sink to format date and time.
The time provides the time point to be converted to string. Returns the formatted string
◆ log()
| void ImFusion::Log::Sink::log |
( |
const LogCapture & | capture | ) |
|
Logs the given message.
Calls logImpl() if the message passes all registered filters.
- Parameters
-
◆ flush()
| virtual void ImFusion::Log::Sink::flush |
( |
| ) |
|
|
pure virtual |
◆ isAccepted()
| bool ImFusion::Log::Sink::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()
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
-
| minLevel | Minimum log level, messages of this level or higher will be logged. |
| category | Category filter, messages where the category contains category will be logged. Leave empty to accept all categories. |
◆ addBlacklistFilter()
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
-
| maxLevel | Maximum log level, messages of this level or lower will not be logged. |
| category | Category filter, messages where the category contains category will not be logged. Leave empty to reject all categories. |
◆ setDateTimeFormatFunction()
Set a callback function for formatting date and time.
Function checks whether fcn is empty and whether its execution with a current time throws an exception (including fmt::format_error). If this is the case, the function will return false and the Sink will continue using a previously set formatting function. If no above issues have occured the function will return true.
◆ logImpl()
| virtual void ImFusion::Log::Sink::logImpl |
( |
const LogCapture & | capture | ) |
|
|
protectedpure virtual |
The documentation for this class was generated from the following file: