|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Writes log messages to a file. More...
#include <file_sink.h>


Public Member Functions | |
| file_sink (const std::string &file_path, bool append=true) | |
| Construct a file sink. | |
| ~file_sink () override | |
| common::VoidResult | write_raw (std::string_view message) override |
| Write a pre-formatted message to the output destination. | |
| common::VoidResult | flush () override |
| Flush any buffered data. | |
| bool | is_healthy () const override |
| Check if the sink is healthy. | |
| std::string | get_name () const override |
| Get the name of this sink. | |
| std::string | get_info () const override |
| Get sink information. | |
| std::string | get_file_path () const |
| Get the file path. | |
Public Member Functions inherited from kcenon::logger::output_sink_interface | |
| virtual | ~output_sink_interface ()=default |
Private Attributes | |
| std::string | file_path_ |
| std::ofstream | file_ |
| std::mutex | mutex_ |
| bool | is_healthy_ |
Writes log messages to a file.
Thread-safe file output sink. Handles file I/O only, no formatting logic.
Definition at line 35 of file file_sink.h.
|
inlineexplicit |
Construct a file sink.
| file_path | Path to the output file |
| append | If true, append to existing file; if false, truncate |
Definition at line 42 of file file_sink.h.
References file_, and is_healthy_.
|
inlineoverride |
|
inlineoverridevirtual |
Flush any buffered data.
Implements kcenon::logger::output_sink_interface.
Definition at line 76 of file file_sink.h.
References file_, kcenon::logger::file_write_failed, is_healthy_, kcenon::logger::make_logger_void_result(), mutex_, and kcenon::common::ok().

|
inline |
Get the file path.
Definition at line 119 of file file_sink.h.
References file_path_.
|
inlineoverridevirtual |
Get sink information.
Reimplemented from kcenon::logger::output_sink_interface.
Definition at line 101 of file file_sink.h.
References file_, file_path_, mutex_, and kcenon::logger::size.
|
inlineoverridevirtual |
Get the name of this sink.
Implements kcenon::logger::output_sink_interface.
Definition at line 97 of file file_sink.h.
|
inlineoverridevirtual |
Check if the sink is healthy.
Implements kcenon::logger::output_sink_interface.
Definition at line 93 of file file_sink.h.
References file_, and is_healthy_.
|
inlineoverridevirtual |
Write a pre-formatted message to the output destination.
| message | Pre-formatted log message |
Implements kcenon::logger::output_sink_interface.
Definition at line 58 of file file_sink.h.
References file_, kcenon::logger::file_write_failed, is_healthy_, kcenon::logger::make_logger_void_result(), mutex_, and kcenon::common::ok().

|
private |
Definition at line 125 of file file_sink.h.
Referenced by file_sink(), flush(), get_info(), is_healthy(), write_raw(), and ~file_sink().
|
private |
Definition at line 124 of file file_sink.h.
Referenced by get_file_path(), and get_info().
|
private |
Definition at line 127 of file file_sink.h.
Referenced by file_sink(), flush(), is_healthy(), and write_raw().
|
mutableprivate |
Definition at line 126 of file file_sink.h.
Referenced by flush(), get_info(), and write_raw().