Base class for sinks.
More...
#include <Sink.h>
|
virtual QUILL_ATTRIBUTE_HOT void | write_log (MacroMetadata const *log_metadata, uint64_t log_timestamp, std::string_view thread_id, std::string_view thread_name, std::string const &process_id, std::string_view logger_name, LogLevel log_level, std::string_view log_level_description, std::string_view log_level_short_code, std::vector< std::pair< std::string, std::string >> const *named_args, std::string_view log_message, std::string_view log_statement)=0 |
| Logs a formatted log message to the sink. More...
|
|
virtual QUILL_ATTRIBUTE_HOT void | flush_sink ()=0 |
| Flushes the sink, synchronizing the associated sink with its controlled output sequence.
|
|
virtual QUILL_ATTRIBUTE_HOT void | run_periodic_tasks () noexcept |
| Executes periodic tasks by the backend thread, providing an opportunity for the user to perform custom tasks. More...
|
|
QUILL_NODISCARD bool | apply_all_filters (MacroMetadata const *log_metadata, uint64_t log_timestamp, std::string_view thread_id, std::string_view thread_name, std::string_view logger_name, LogLevel log_level, std::string_view log_message, std::string_view log_statement) |
| Applies all registered filters to the log record. More...
|
|
|
class | detail::BackendWorker |
|
◆ add_filter()
void Sink::add_filter |
( |
std::unique_ptr< Filter > |
filter | ) |
|
|
inline |
Adds a new filter to the sink.
- Note
- Thread safe.
- Parameters
-
filter | Unique pointer to the filter instance. |
◆ apply_all_filters()
QUILL_NODISCARD bool Sink::apply_all_filters |
( |
MacroMetadata const * |
log_metadata, |
|
|
uint64_t |
log_timestamp, |
|
|
std::string_view |
thread_id, |
|
|
std::string_view |
thread_name, |
|
|
std::string_view |
logger_name, |
|
|
LogLevel |
log_level, |
|
|
std::string_view |
log_message, |
|
|
std::string_view |
log_statement |
|
) |
| |
|
inlineprotected |
Applies all registered filters to the log record.
- Note
- Called internally by the backend worker thread.
- Parameters
-
log_metadata | Pointer to the macro metadata. |
log_timestamp | Timestamp of the log event. |
thread_id | ID of the thread. |
thread_name | Name of the thread. |
logger_name | Name of the logger. |
log_level | Log level of the message. |
log_message | The log message. |
log_statement | The log message. |
- Returns
- True if the log record passes all filters, false otherwise.
◆ get_log_level_filter()
QUILL_NODISCARD LogLevel Sink::get_log_level_filter |
( |
| ) |
const |
|
inlinenoexcept |
Returns the current log level filter set on the sink.
- Note
- Thread safe.
- Returns
- The current log level filter.
◆ run_periodic_tasks()
virtual QUILL_ATTRIBUTE_HOT void Sink::run_periodic_tasks |
( |
| ) |
|
|
inlineprotectedvirtualnoexcept |
Executes periodic tasks by the backend thread, providing an opportunity for the user to perform custom tasks.
For example, batch committing to a database, or any other desired periodic operations.
- Note
- It is recommended to avoid heavy operations within this function as it may affect performance of the backend thread.
◆ set_log_level_filter()
void Sink::set_log_level_filter |
( |
LogLevel |
log_level | ) |
|
|
inline |
Sets a log level filter on the sink.
- Note
- Thread safe.
- Parameters
-
log_level | The log level severity. |
◆ write_log()
virtual QUILL_ATTRIBUTE_HOT void Sink::write_log |
( |
MacroMetadata const * |
log_metadata, |
|
|
uint64_t |
log_timestamp, |
|
|
std::string_view |
thread_id, |
|
|
std::string_view |
thread_name, |
|
|
std::string const & |
process_id, |
|
|
std::string_view |
logger_name, |
|
|
LogLevel |
log_level, |
|
|
std::string_view |
log_level_description, |
|
|
std::string_view |
log_level_short_code, |
|
|
std::vector< std::pair< std::string, std::string >> const * |
named_args, |
|
|
std::string_view |
log_message, |
|
|
std::string_view |
log_statement |
|
) |
| |
|
protectedpure virtual |
Logs a formatted log message to the sink.
- Note
- Accessor for backend processing.
- Parameters
-
log_metadata | Pointer to the macro metadata. |
log_timestamp | Timestamp of the log event. |
thread_id | ID of the thread. |
thread_name | Name of the thread. |
process_id | Process Id |
logger_name | Name of the logger. |
log_level | Log level of the message. |
log_level_description | Description of the log level. |
log_level_short_code | Short code representing the log level. |
named_args | Vector of key-value pairs of named args |
log_message | The log message. |
log_statement | The log statement. |
Implemented in ConsoleSink, StreamSink, detail::JsonSink< StreamSink >, detail::JsonSink< FileSink >, NullSink, and CustomJsonFileSink.
The documentation for this class was generated from the following file: