95 std::unique_ptr<output_sink_interface> sink)
97 ,
sink_(std::move(sink))
100 throw std::invalid_argument(
"Formatter cannot be null");
103 throw std::invalid_argument(
"Sink cannot be null");
133 std::string formatted =
formatter_->format(entry);
136 return sink_->write_raw(formatted);
148 return sink_->flush();
173 return sink_->is_healthy();
204 std::unique_ptr<output_sink_interface>
sink_;
227 std::unique_ptr<log_formatter_interface> formatter,
228 std::unique_ptr<output_sink_interface> sink)
230 return std::make_unique<composite_writer>(
231 std::move(formatter),
Coordinates formatting and output through a pipeline.
std::string get_name() const override
output_sink_interface * get_sink() const
Get the sink.
~composite_writer() override
Destructor.
std::unique_ptr< log_formatter_interface > formatter_
Formatting stage.
composite_writer(std::unique_ptr< log_formatter_interface > formatter, std::unique_ptr< output_sink_interface > sink)
Construct a composite writer.
std::unique_ptr< output_sink_interface > sink_
Output stage.
common::VoidResult flush() override
Flush the sink.
common::VoidResult write(const log_entry &entry) override
Write a log entry through the pipeline.
bool is_healthy() const override
Check if the writer is healthy.
log_formatter_interface * get_formatter() const
Get the formatter.
Base interface for all log writers and decorators.
Abstract interface for log output destinations (I/O only)
Base interface for all log writers and decorators.
std::unique_ptr< composite_writer > make_composite_writer(std::unique_ptr< log_formatter_interface > formatter, std::unique_ptr< output_sink_interface > sink)
Interface for log output destinations (Single Responsibility Principle) kcenon.
Tag interface for composite writers.
Represents a single log entry with all associated metadata.
Writer category interfaces and type traits kcenon.