|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Coordinates formatting and output through a pipeline. More...
#include <composite_writer.h>


Public Member Functions | |
| composite_writer (std::unique_ptr< log_formatter_interface > formatter, std::unique_ptr< output_sink_interface > sink) | |
| Construct a composite writer. | |
| ~composite_writer () override | |
| Destructor. | |
| common::VoidResult | write (const log_entry &entry) override |
| Write a log entry through the pipeline. | |
| common::VoidResult | flush () override |
| Flush the sink. | |
| std::string | get_name () const override |
| bool | is_healthy () const override |
| Check if the writer is healthy. | |
| log_formatter_interface * | get_formatter () const |
| Get the formatter. | |
| output_sink_interface * | get_sink () const |
| Get the sink. | |
Public Member Functions inherited from kcenon::logger::log_writer_interface | |
| virtual | ~log_writer_interface ()=default |
| virtual common::VoidResult | close () |
| Close the writer and release resources. | |
| virtual auto | is_open () const -> bool |
| Check if writer is open and ready. | |
Private Attributes | |
| std::unique_ptr< log_formatter_interface > | formatter_ |
| Formatting stage. | |
| std::unique_ptr< output_sink_interface > | sink_ |
| Output stage. | |
Additional Inherited Members | |
Static Public Attributes inherited from kcenon::logger::composite_writer_tag | |
| static constexpr writer_category | category = writer_category::composite |
Coordinates formatting and output through a pipeline.
Implements the Composite and Pipeline patterns to create a flexible logging architecture. This writer:
Benefits:
Category: Composite (combines formatter and sink through Pipeline pattern)
Definition at line 77 of file composite_writer.h.
|
inline |
Construct a composite writer.
| formatter | Formatter to use for converting log_entry to string |
| sink | Sink to use for outputting formatted messages |
Creates a writer that pipelines log entries through the provided formatter and sink.
| std::invalid_argument | if formatter or sink is nullptr |
Definition at line 94 of file composite_writer.h.
References formatter_, and sink_.
|
inlineoverride |
Destructor.
Ensures the sink is flushed before destruction.
Definition at line 114 of file composite_writer.h.
References flush().

|
inlineoverridevirtual |
Flush the sink.
Delegates flushing to the sink.
Implements kcenon::logger::log_writer_interface.
Definition at line 147 of file composite_writer.h.
References sink_.
Referenced by ~composite_writer().

|
inline |
Get the formatter.
Definition at line 185 of file composite_writer.h.
References formatter_.
|
inlineoverridevirtual |
Implements kcenon::logger::log_writer_interface.
Definition at line 159 of file composite_writer.h.
References formatter_, and sink_.
|
inline |
Get the sink.
Definition at line 198 of file composite_writer.h.
References sink_.
|
inlineoverridevirtual |
Check if the writer is healthy.
A composite writer is healthy if its sink is healthy. Formatters are assumed to always be healthy.
Implements kcenon::logger::log_writer_interface.
Definition at line 172 of file composite_writer.h.
References sink_.
|
inlineoverridevirtual |
Write a log entry through the pipeline.
| entry | The log entry to write |
Pipeline stages:
Implements kcenon::logger::log_writer_interface.
Definition at line 131 of file composite_writer.h.
References formatter_, and sink_.
|
private |
Formatting stage.
Definition at line 203 of file composite_writer.h.
Referenced by composite_writer(), get_formatter(), get_name(), and write().
|
private |
Output stage.
Definition at line 204 of file composite_writer.h.
Referenced by composite_writer(), flush(), get_name(), get_sink(), is_healthy(), and write().