|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Classes | |
| struct | error_context |
| Structured error context for debugging. More... | |
| class | file_utils |
| File utility functions for path validation and sanitization. More... | |
| class | string_utils |
| String utility functions for log formatting and conversion. More... | |
| class | time_utils |
| Time utility functions for timestamp formatting. More... | |
Functions | |
| void | log_error_context (const error_context &context) |
| Log error to stderr with context. | |
| template<typename F > | |
| common::VoidResult | try_write_operation (F &&operation, logger_error_code default_error_code=logger_error_code::file_write_failed) |
| Error handling helper for write operations. | |
| template<typename F > | |
| common::VoidResult | try_open_operation (F &&operation) |
| Error handling helper for file open operations. | |
| template<typename F > | |
| common::VoidResult | try_network_operation (F &&operation) |
| Error handling helper for network operations. | |
| template<typename F > | |
| common::VoidResult | try_encryption_operation (F &&operation) |
| Error handling helper for encryption operations. | |
| common::VoidResult | check_condition (bool condition, logger_error_code error_code, const std::string &message) |
| Condition verification helper. | |
| template<typename Stream > | |
| common::VoidResult | check_stream_state (const Stream &stream, const std::string &operation_name="operation") |
| Stream state verification helper. | |
| common::VoidResult | check_file_exists (const std::filesystem::path &path) |
| File existence verification helper. | |
| common::VoidResult | ensure_directory_exists (const std::filesystem::path &dir) |
| Directory creation helper. | |
| template<typename F > | |
| void | safe_destructor_operation (const std::string &operation_name, F &&operation) noexcept |
| Safe operation execution for destructors. | |
| template<typename F > | |
| void | safe_destructor_result_operation (const std::string &operation_name, F &&operation) noexcept |
| Safe operation with result for destructors. | |
|
inline |
Condition verification helper.
Checks a boolean condition and returns an error if the condition is false. This helper reduces boilerplate code for precondition checks.
Usage example:
| condition | The condition to check |
| error_code | Error code to return if condition is false |
| message | Error message |
Definition at line 282 of file error_handling_utils.h.
References kcenon::logger::make_logger_void_result(), and kcenon::common::ok().
Referenced by kcenon::logger::file_writer::open_internal().


|
inline |
File existence verification helper.
Checks if a file exists at the given path.
| path | The file path to check |
Definition at line 344 of file error_handling_utils.h.
References kcenon::logger::file_open_failed, kcenon::logger::file_permission_denied, kcenon::logger::make_logger_void_result(), and kcenon::common::ok().

|
inline |
Stream state verification helper.
Checks if a stream is in a good state and returns an appropriate error if not. This is a specialized version of check_condition for stream operations.
| Stream | Stream type (e.g., std::ofstream, std::ifstream) |
| stream | The stream to check |
| operation_name | Name of the operation for error message (e.g., "write", "open") |
Definition at line 305 of file error_handling_utils.h.
References kcenon::logger::file_write_failed, kcenon::logger::make_logger_void_result(), and kcenon::common::ok().
Referenced by kcenon::logger::file_writer::flush(), kcenon::logger::console_writer::write(), and kcenon::logger::file_writer::write().


|
inline |
Directory creation helper.
Creates a directory if it doesn't exist, with proper error handling.
| dir | The directory path to create |
Definition at line 369 of file error_handling_utils.h.
References kcenon::logger::file_permission_denied, kcenon::logger::make_logger_void_result(), kcenon::common::ok(), and try_open_operation().
Referenced by kcenon::logger::file_writer::open_internal(), and kcenon::logger::rotating_file_writer::perform_rotation().


|
inline |
Log error to stderr with context.
Used primarily in destructors where throwing exceptions is not allowed. Provides diagnostic information without propagating errors.
| context | Error context to log |
Definition at line 129 of file error_handling_utils.h.
References kcenon::logger::utils::error_context::to_string().
Referenced by safe_destructor_operation(), and safe_destructor_result_operation().


|
inlinenoexcept |
Safe operation execution for destructors.
Executes an operation in a destructor-safe manner. Exceptions are caught and logged to stderr instead of being propagated, preventing std::terminate.
This function should be used in destructors where throwing exceptions would be unsafe.
Usage example:
| F | Callable type |
| operation_name | Name of the operation for logging |
| operation | The operation to execute |
Definition at line 410 of file error_handling_utils.h.
References kcenon::logger::destructor_cleanup_failed, and log_error_context().
Referenced by kcenon::logger::network_writer::~network_writer().


|
inlinenoexcept |
Safe operation with result for destructors.
Similar to safe_destructor_operation but for operations that return common::VoidResult. Logs both exceptions and result errors.
| F | Callable type that returns common::VoidResult |
| operation_name | Name of the operation for logging |
| operation | The operation to execute |
Definition at line 446 of file error_handling_utils.h.
References kcenon::logger::destructor_cleanup_failed, kcenon::logger::get_logger_error_code(), and log_error_context().
Referenced by kcenon::logger::batch_writer::~batch_writer().


| common::VoidResult kcenon::logger::utils::try_encryption_operation | ( | F && | operation | ) |
Error handling helper for encryption operations.
Specialized version of try_write_operation for encryption operations. Uses encryption_failed as the default error code.
| F | Callable type that returns common::VoidResult |
| operation | The operation to execute |
Definition at line 254 of file error_handling_utils.h.
References kcenon::logger::encryption_failed, and try_write_operation().

| common::VoidResult kcenon::logger::utils::try_network_operation | ( | F && | operation | ) |
Error handling helper for network operations.
Specialized version of try_write_operation for network operations. Uses network_send_failed as the default error code.
| F | Callable type that returns common::VoidResult |
| operation | The operation to execute |
Definition at line 236 of file error_handling_utils.h.
References kcenon::logger::network_send_failed, and try_write_operation().

| common::VoidResult kcenon::logger::utils::try_open_operation | ( | F && | operation | ) |
Error handling helper for file open operations.
Specialized version of try_write_operation for file open operations. Uses file_open_failed as the default error code.
| F | Callable type that returns common::VoidResult |
| operation | The operation to execute |
Definition at line 218 of file error_handling_utils.h.
References kcenon::logger::file_open_failed, and try_write_operation().
Referenced by ensure_directory_exists(), kcenon::logger::file_writer::open_internal(), and kcenon::logger::rotating_file_writer::perform_rotation().


| common::VoidResult kcenon::logger::utils::try_write_operation | ( | F && | operation, |
| logger_error_code | default_error_code = logger_error_code::file_write_failed ) |
Error handling helper for write operations.
This function wraps write operations with comprehensive exception handling, mapping different exception types to appropriate logger error codes.
Usage example:
| F | Callable type that returns common::VoidResult |
| operation | The operation to execute |
| default_error_code | Error code to use for unexpected exceptions (default: file_write_failed) |
Definition at line 156 of file error_handling_utils.h.
References kcenon::logger::buffer_overflow, kcenon::logger::file_permission_denied, kcenon::logger::file_write_failed, and kcenon::logger::make_logger_void_result().
Referenced by kcenon::logger::rotating_file_writer::cleanup_old_files(), kcenon::logger::console_writer::flush(), kcenon::logger::file_writer::flush(), kcenon::logger::rotating_file_writer::get_backup_files(), kcenon::logger::rotating_file_writer::perform_rotation(), try_encryption_operation(), try_network_operation(), try_open_operation(), kcenon::logger::console_writer::write(), and kcenon::logger::file_writer::write().

