|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Combines async writer for normal logs with critical_writer for safety. More...
#include <critical_writer.h>


Public Member Functions | |
| hybrid_writer (log_writer_ptr wrapped_writer, critical_writer_config critical_config={}, std::size_t async_queue_size=10000) | |
| ~hybrid_writer () override | |
| common::VoidResult | write (const log_entry &entry) override |
| Write a log entry. | |
| common::VoidResult | flush () override |
| Flush any buffered data. | |
| bool | is_healthy () const override |
| Check if the writer is healthy and operational. | |
| std::string | get_name () const override |
| void | set_use_color (bool use_color) override |
| Set whether to use color output (if supported) | |
Public Member Functions inherited from kcenon::logger::base_writer | |
| base_writer (std::unique_ptr< log_formatter_interface > formatter=nullptr) | |
| Constructor with optional formatter. | |
| virtual | ~base_writer ()=default |
| bool | use_color () const |
| Get current color output setting. | |
| log_formatter_interface * | get_formatter () const |
| Get the current formatter. | |
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 | |
| log_writer_ptr | critical_writer_ |
| std::size_t | async_queue_size_ |
Additional Inherited Members | |
Static Public Attributes inherited from kcenon::logger::composite_writer_tag | |
| static constexpr writer_category | category = writer_category::composite |
Static Public Attributes inherited from kcenon::logger::decorator_writer_tag | |
| static constexpr writer_category | category = writer_category::decorator |
Protected Member Functions inherited from kcenon::logger::base_writer | |
| std::string | format_log_entry (const log_entry &entry) const |
| Format a log entry using the current formatter. | |
Combines async writer for normal logs with critical_writer for safety.
This is a convenience class that automatically configures:
Category: Composite (combines async and critical behavior), Decorator
Definition at line 247 of file critical_writer.h.
|
explicit |
Definition at line 258 of file critical_writer.cpp.
References critical_writer_.
|
overridedefault |
|
overridevirtual |
Flush any buffered data.
Forces any buffered log entries to be written to the underlying output destination immediately. This method should be called before program termination or when immediate persistence is required.
Implements kcenon::logger::base_writer.
Definition at line 279 of file critical_writer.cpp.
References critical_writer_.
|
overridevirtual |
Implements kcenon::logger::base_writer.
Definition at line 287 of file critical_writer.cpp.
References critical_writer_.
|
overridevirtual |
Check if the writer is healthy and operational.
Used for health monitoring and automatic failover. A writer might be unhealthy if its destination is unavailable (e.g., disk full, network disconnected).
Reimplemented from kcenon::logger::base_writer.
Definition at line 283 of file critical_writer.cpp.
References critical_writer_.
|
overridevirtual |
Set whether to use color output (if supported)
| use_color | true to enable color output, false to disable |
Enables or disables ANSI color codes in formatted output. Only affects writers that output to terminals supporting color.
Reimplemented from kcenon::logger::base_writer.
Definition at line 291 of file critical_writer.cpp.
References kcenon::logger::base_writer::use_color().

|
overridevirtual |
Write a log entry.
| entry | The log entry to write |
Implements kcenon::logger::base_writer.
Definition at line 274 of file critical_writer.cpp.
References critical_writer_.
|
private |
Definition at line 272 of file critical_writer.h.
|
private |
Definition at line 271 of file critical_writer.h.
Referenced by flush(), get_name(), hybrid_writer(), is_healthy(), and write().