|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Namespaces | |
| namespace | adapters |
| namespace | analysis |
| namespace | async |
| namespace | backends |
| namespace | core |
| namespace | detail |
| namespace | filters |
| namespace | formatters |
| namespace | integration |
| namespace | memory |
| namespace | metrics |
| namespace | monitoring |
| namespace | otlp |
| namespace | routing |
| namespace | safety |
| namespace | sampling |
| namespace | security |
| namespace | server |
| namespace | sinks |
| namespace | strategies |
| namespace | structured |
| namespace | utils |
Classes | |
| class | async_writer |
| Asynchronous wrapper for log writers. More... | |
| interface | async_writer_tag |
| Tag interface for asynchronous writers. More... | |
| class | base_formatter |
| Base implementation for log formatters. More... | |
| class | base_writer |
| Abstract base class for all log output writers. More... | |
| class | basic_monitor |
| Basic monitoring implementation. More... | |
| class | batch_writer |
| Batch writer that accumulates log entries and writes them in batches. More... | |
| class | buffered_writer |
| Decorator that buffers log entries before writing to wrapped writer. More... | |
| class | compact_formatter |
| Compact formatter for minimal output. More... | |
| class | composite_filter |
| Combine multiple filters with AND/OR logic. More... | |
| class | composite_strategy |
| Combines multiple configuration strategies. More... | |
| class | composite_writer |
| Coordinates formatting and output through a pipeline. More... | |
| interface | composite_writer_tag |
| Tag interface for composite writers. More... | |
| class | config_strategy_interface |
| Abstract interface for logger configuration strategies. More... | |
| class | console_sink |
| Outputs log messages to console (stdout or stderr) More... | |
| class | console_writer |
| Core console writer for logging to stdout/stderr. More... | |
| class | critical_writer |
| Synchronous wrapper ensuring critical logs are never lost. More... | |
| struct | critical_writer_config |
| Configuration for critical log writer. More... | |
| class | decorator_writer_base |
| Abstract base class for decorator pattern log writers. More... | |
| interface | decorator_writer_tag |
| Tag interface for decorator writers. More... | |
| class | deployment_strategy |
| Configuration strategy based on deployment environment. More... | |
| struct | encrypted_log_header |
| Header prepended to each encrypted log entry. More... | |
| class | encrypted_writer |
| Decorator that encrypts log data before writing. More... | |
| struct | encryption_config |
| Configuration for encrypted_writer. More... | |
| class | environment_strategy |
| Configuration strategy based on environment variables. More... | |
| class | file_sink |
| Writes log messages to a file. More... | |
| class | file_writer |
| Core file writer for logging to files. More... | |
| class | filter_factory |
| Factory for creating log filter instances. More... | |
| class | filtered_writer |
| Decorator that applies a filter to a wrapped writer. More... | |
| struct | format_options |
| Configuration options for log formatting. More... | |
| class | formatted_writer |
| Decorator that applies a formatter to a wrapped writer. More... | |
| class | formatter_factory |
| Factory for creating log formatter instances. More... | |
| class | function_filter |
| Filter logs by custom function. More... | |
| class | health_check_result |
| Health check result. More... | |
| class | hybrid_writer |
| Combines async writer for normal logs with critical_writer for safety. More... | |
| struct | is_async_writer |
| Type trait to check if a writer is asynchronous. More... | |
| struct | is_composite_writer |
| Type trait to check if a writer is composite. More... | |
| struct | is_decorator_writer |
| Type trait to check if a writer is a decorator. More... | |
| struct | is_sync_writer |
| Type trait to check if a writer is synchronous. More... | |
| class | json_formatter |
| JSON formatter for structured logging. More... | |
| class | level_filter |
| Filter logs by minimum level. More... | |
| class | log_collector |
| Asynchronous log collector for high-performance logging. More... | |
| class | log_collector_jthread_worker |
| Worker thread for log processing with jthread compatibility. More... | |
| struct | log_collector_shared_state |
| Shared state for log processing - survives impl destruction. More... | |
| class | log_context_scope |
| RAII guard for structured logging context. More... | |
| class | log_context_storage |
| Thread-local storage for structured logging context fields. More... | |
| class | log_decryptor |
| Utility class for decrypting encrypted log files. More... | |
| struct | log_entry |
| Represents a single log entry with all associated metadata. More... | |
| class | log_filter |
| Base class for log filtering. More... | |
| interface | log_filter_interface |
| Interface for log filters. More... | |
| class | log_formatter_interface |
| Abstract interface for log message formatters. More... | |
| interface | log_sink_interface |
| Interface for log sinks. More... | |
| interface | log_writer_interface |
| Base interface for all log writers and decorators. More... | |
| class | logfmt_formatter |
| Formatter that outputs logfmt-structured log messages. More... | |
| class | logger |
| Main logger implementation providing high-performance logging facilities. More... | |
| class | logger_builder |
| Builder pattern for logger construction with validation. More... | |
| struct | logger_config |
| Configuration structure for logger with validation. More... | |
| class | logger_config_builder |
| Fluent builder for logger_config. More... | |
| struct | metric_value |
| Single metric value with metadata. More... | |
| class | monitoring_data |
| Collection of metrics. More... | |
| class | monitoring_interface |
| Abstract monitoring interface. More... | |
| class | network_reconnect_jthread_worker |
| Worker thread for reconnection attempts with jthread compatibility. More... | |
| class | network_send_jthread_worker |
| Worker thread for sending buffered logs with jthread compatibility. More... | |
| class | network_writer |
| Sends logs over network (TCP/UDP) More... | |
| class | otlp_writer |
| OTLP log exporter for OpenTelemetry integration. More... | |
| class | output_sink_interface |
| Abstract interface for log output destinations (I/O only) More... | |
| class | performance_strategy |
| Configuration strategy for performance tuning. More... | |
| class | plain_formatter |
| Simple plain text formatter. More... | |
| class | queued_writer_base |
| Abstract base class for queue-based log writers. More... | |
| class | regex_filter |
| Filter logs by regex pattern. More... | |
| class | result |
| class | rotating_file_writer |
| File writer with automatic log rotation support. More... | |
| class | scoped_context |
| Convenience class for setting a single context field with RAII. More... | |
| class | scoped_context_guard |
| RAII guard for automatic context management. More... | |
| class | small_string |
| Small String Optimization (SSO) implementation. More... | |
| struct | source_location |
| Source code location information for debugging. More... | |
| class | structured_log_builder |
| Fluent builder for creating structured log entries. More... | |
| interface | sync_writer_tag |
| Tag interface for synchronous writers. More... | |
| class | template_formatter |
| Customizable formatter using template strings with placeholders. More... | |
| class | thread_safe_writer |
| Base class providing automatic thread-safety for writer implementations. More... | |
| class | thread_system_monitor_adapter |
| Adapter to use thread_system's monitoring capabilities. More... | |
| class | timestamp_formatter |
| Default formatter with human-readable timestamp format. More... | |
| class | unified_log_context |
| Unified interface for managing all types of logging context. More... | |
| class | writer_factory |
| Factory for creating log writer instances. More... | |
Concepts | |
| concept | SyncWriter |
| Concept for synchronous writers. | |
| concept | AsyncWriter |
| Concept for asynchronous writers. | |
| concept | DecoratorWriter |
| Concept for decorator writers. | |
| concept | CompositeWriter |
| Concept for composite writers. | |
Typedefs | |
| using | error_code = logger_error_code |
| using | health_status = logger_system::health_status |
| using | kcenon::logger::overflow_policy = logger_system::overflow_policy |
| using | logger_metrics = metrics::logger_performance_stats |
| using | performance_metrics = metrics::logger_performance_stats |
| using | small_string_64 = small_string<64> |
| using | small_string_128 = small_string<128> |
| using | small_string_256 = small_string<256> |
| using | small_string_512 = small_string<512> |
| using | config_strategy_factory_fn = std::function<std::unique_ptr<config_strategy_interface>()> |
| Factory function type for creating configuration strategies. | |
| using | context_value = std::variant<std::monostate, bool, int64_t, double, std::string> |
| Value type for unified context storage. | |
| using | log_value = std::variant<std::string, int64_t, double, bool> |
| Value type for structured logging fields. | |
| using | log_fields = std::unordered_map<std::string, log_value> |
| Type alias for structured fields map. | |
| using | formatter_factory = std::function<std::unique_ptr<log_formatter_interface>()> |
| Factory function type for creating formatters. | |
| using | log_writer_ptr = std::unique_ptr<log_writer_interface> |
| Type alias for writer unique pointer. | |
| using | output_sink_factory = std::function<std::unique_ptr<output_sink_interface>()> |
Functions | |
| std::string | logger_error_to_string (logger_error_code code) |
| Convert logger_error_code to string representation. | |
| common::VoidResult | make_logger_void_result (logger_error_code code, const std::string &message="") |
| common::VoidResult | make_logger_void_success () |
| logger_error_code | get_logger_error_code (const common::VoidResult &result) |
| bool | has_logger_error (const common::VoidResult &result) |
| Check if a VoidResult contains an error. | |
| std::string | get_logger_error_message (const common::VoidResult &result) |
| Get error message from a VoidResult. | |
| template<typename T > | |
| constexpr writer_category | get_writer_category () |
| Get the primary category of a writer type. | |
| constexpr const char * | to_string (writer_category cat) noexcept |
| Get string representation of writer category. | |
| std::unique_ptr< batch_writer > | make_batch_writer (log_writer_ptr writer, size_t batch_size=100, std::chrono::milliseconds flush_interval=std::chrono::milliseconds{1000}) |
| Factory function to create a batch writer. | |
| std::unique_ptr< buffered_writer > | make_buffered_writer (std::unique_ptr< log_writer_interface > writer, size_t max_entries=buffered_writer::DEFAULT_BUFFER_SIZE, std::chrono::milliseconds flush_interval=buffered_writer::DEFAULT_FLUSH_INTERVAL) |
| Factory function to create a buffered writer. | |
| std::unique_ptr< composite_writer > | make_composite_writer (std::unique_ptr< log_formatter_interface > formatter, std::unique_ptr< output_sink_interface > sink) |
| std::unique_ptr< filtered_writer > | make_filtered_writer (std::unique_ptr< log_writer_interface > writer, std::unique_ptr< log_filter_interface > filter) |
| Factory function to create a filtered writer. | |
| std::unique_ptr< formatted_writer > | make_formatted_writer (std::unique_ptr< log_writer_interface > writer, std::unique_ptr< log_formatter_interface > formatter) |
| Factory function to create a formatted writer. | |
| log_entry | copy_log_entry (const log_entry &entry) |
| Creates a copy of a log_entry for queue storage. | |
| std::string | health_status_to_string (health_status status) |
| Convert health status to string. | |
| std::string | metric_type_to_string (metric_type type) |
| Convert metric type to string. | |
Variables | |
| template<typename T > | |
| constexpr bool | is_sync_writer_v = is_sync_writer<T>::value |
| template<typename T > | |
| constexpr bool | is_async_writer_v = is_async_writer<T>::value |
| template<typename T > | |
| constexpr bool | is_decorator_writer_v = is_decorator_writer<T>::value |
| template<typename T > | |
| constexpr bool | is_composite_writer_v = is_composite_writer<T>::value |
| using kcenon::logger::config_strategy_factory_fn = std::function<std::unique_ptr<config_strategy_interface>()> |
Factory function type for creating configuration strategies.
Definition at line 77 of file config_strategy_interface.h.
| using kcenon::logger::context_value = std::variant<std::monostate, bool, int64_t, double, std::string> |
Value type for unified context storage.
Supports common types used in logging context:
Definition at line 60 of file unified_log_context.h.
Definition at line 573 of file error_codes.h.
| using kcenon::logger::formatter_factory = std::function<std::unique_ptr<log_formatter_interface>()> |
Factory function type for creating formatters.
Can be used with dependency injection systems to create formatters dynamically.
Definition at line 144 of file log_formatter_interface.h.
| using kcenon::logger::log_fields = std::unordered_map<std::string, log_value> |
Type alias for structured fields map.
Definition at line 75 of file log_entry.h.
| using kcenon::logger::log_value = std::variant<std::string, int64_t, double, bool> |
Value type for structured logging fields.
Supports common types used in structured logging:
Definition at line 69 of file log_entry.h.
| using kcenon::logger::log_writer_ptr = std::unique_ptr<log_writer_interface> |
Type alias for writer unique pointer.
Convenience alias for managing writer lifetime and ownership
Definition at line 151 of file log_writer_interface.h.
| using kcenon::logger::output_sink_factory = std::function<std::unique_ptr<output_sink_interface>()> |
Definition at line 78 of file output_sink_interface.h.
|
export |
| using kcenon::logger::small_string_128 = small_string<128> |
| using kcenon::logger::small_string_256 = small_string<256> |
Definition at line 420 of file small_string.h.
| using kcenon::logger::small_string_512 = small_string<512> |
Definition at line 421 of file small_string.h.
| using kcenon::logger::small_string_64 = small_string<64> |
Definition at line 418 of file small_string.h.
|
strong |
Categories for organizing context entries.
Context entries are categorized to enable selective clearing and querying. Each category represents a different source or purpose for the context data.
| Enumerator | |
|---|---|
| custom | User-defined custom fields. |
| trace | Distributed tracing (trace_id, span_id, parent_span_id) |
| request | Request metadata (request_id, correlation_id) |
| otel | OpenTelemetry specific fields. |
Definition at line 72 of file unified_log_context.h.
|
strong |
Deployment environment types.
Definition at line 29 of file deployment_strategy.h.
|
strong |
Supported encryption algorithms for log encryption.
| Enumerator | |
|---|---|
| aes_256_gcm | AES-256 in GCM mode (recommended) |
| aes_256_cbc | AES-256 in CBC mode (legacy support) |
| chacha20_poly1305 | ChaCha20-Poly1305 (modern alternative) |
Definition at line 76 of file encrypted_writer.h.
|
strong |
Pre-defined format types.
| Enumerator | |
|---|---|
| plain | Plain text with timestamps. |
| json | JSON structured format. |
| logfmt | Logfmt key=value format. |
| templated | Template-based custom format. |
| compact | Compact single-line format. |
Definition at line 33 of file formatter_factory.h.
|
exportstrong |
Health status levels.
| Enumerator | |
|---|---|
| healthy | Everything is working normally. |
| degraded | Some issues but still operational. |
| unhealthy | Major issues, may not be operational. |
| unknown | Status cannot be determined. |
Definition at line 27 of file monitoring_interface.h.
|
strong |
Error codes specific to the logger system.
These error codes extend the thread_module error codes with logger-specific error conditions.
Definition at line 224 of file error_codes.h.
|
strong |
Types of metrics that can be recorded by the logger.
|
strong |
Metric types for categorization.
Definition at line 37 of file monitoring_interface.h.
|
strong |
Performance tuning presets.
Definition at line 28 of file performance_strategy.h.
|
strong |
Determines when log rotation should occur.
| Enumerator | |
|---|---|
| size | Rotate based on file size only. |
| daily | Rotate daily at midnight. |
| hourly | Rotate every hour. |
| size_and_time | Rotate based on both size and time. |
Definition at line 29 of file rotating_file_writer.h.
|
strong |
Categories of log writers based on operational behavior.
Writers are categorized by their primary operational mode. This categorization helps in:
Definition at line 50 of file writer_category.h.
Creates a copy of a log_entry for queue storage.
Since log_entry is move-only, this helper function creates a new log_entry by copying the essential fields from the source.
| entry | The source log entry to copy from |
Definition at line 33 of file queued_writer_base.h.
References kcenon::logger::log_entry::level, kcenon::logger::log_entry::location, kcenon::logger::log_entry::message, kcenon::logger::log_entry::timestamp, and kcenon::logger::small_string< SSO_SIZE >::to_string().
Referenced by kcenon::logger::queued_writer_base< Container >::enqueue_entry(), kcenon::logger::queued_writer_base< Container >::enqueue_entry(), and kcenon::logger::batch_writer::write().


|
inline |
Definition at line 543 of file error_codes.h.
References success.
Referenced by kcenon::logger::security::secure_key_storage::load_key(), kcenon::logger::utils::safe_destructor_result_operation(), and kcenon::logger::security::path_validator::safe_join().

|
inline |
Get error message from a VoidResult.
| result | The VoidResult to get message from |
Definition at line 566 of file error_codes.h.
Referenced by kcenon::logger::security::secure_key_storage::load_key(), kcenon::logger::security::path_validator::safe_join(), and kcenon::logger::encrypted_writer::write().

|
constexpr |
Get the primary category of a writer type.
| T | Writer type |
Returns the primary category for a writer type. Priority order: composite > decorator > async > sync
Definition at line 272 of file writer_category.h.
References asynchronous, composite, decorator, is_async_writer_v, is_composite_writer_v, is_decorator_writer_v, is_sync_writer_v, and synchronous.
|
inline |
Check if a VoidResult contains an error.
| result | The VoidResult to check |
Definition at line 556 of file error_codes.h.
|
inline |
Convert health status to string.
| status | The health status |
Definition at line 284 of file monitoring_interface.h.
|
inline |
Convert logger_error_code to string representation.
| code | The error code to convert |
Definition at line 304 of file error_codes.h.
References async_operation_already_running, async_operation_not_running, authentication_failed, batch_processing_failed, batch_processing_timeout, buffer_overflow, component_not_found, configuration_conflict, configuration_missing, creation_failed, decryption_failed, destructor_cleanup_failed, di_not_available, encryption_failed, file_open_failed, file_permission_denied, file_read_failed, file_rotation_failed, file_write_failed, filter_error, flush_timeout, formatter_error, insecure_permissions, invalid_argument, invalid_configuration, invalid_filename, invalid_key_size, metrics_collection_failed, metrics_not_available, network_connection_failed, network_send_failed, network_timeout, not_implemented, operation_failed, path_traversal_detected, processing_failed, queue_full, queue_overflow_blocked, queue_overflow_dropped, queue_stopped, registration_failed, sanitization_failed, success, unknown_error, writer_already_exists, writer_configuration_error, writer_initialization_failed, writer_not_available, writer_not_found, writer_not_healthy, and writer_operation_failed.
Referenced by make_logger_void_result(), and kcenon::logger::utils::error_context::to_string().

| std::unique_ptr< batch_writer > kcenon::logger::make_batch_writer | ( | log_writer_ptr | writer, |
| size_t | batch_size = 100, | ||
| std::chrono::milliseconds | flush_interval = std::chrono::milliseconds{1000} ) |
Factory function to create a batch writer.
| writer | The underlying writer to wrap |
| batch_size | Maximum batch size |
| flush_interval | Auto-flush interval in milliseconds |
Definition at line 145 of file batch_writer.cpp.
References kcenon::logger::batch_writer::config::flush_interval, and kcenon::logger::batch_writer::config::max_batch_size.
| std::unique_ptr< buffered_writer > kcenon::logger::make_buffered_writer | ( | std::unique_ptr< log_writer_interface > | writer, |
| size_t | max_entries = buffered_writer::DEFAULT_BUFFER_SIZE, | ||
| std::chrono::milliseconds | flush_interval = buffered_writer::DEFAULT_FLUSH_INTERVAL ) |
Factory function to create a buffered writer.
| writer | The writer to wrap |
| max_entries | Maximum buffer size |
| flush_interval | Time between automatic flushes |
| std::invalid_argument | if writer is nullptr or max_entries is 0 |
Definition at line 146 of file buffered_writer.cpp.
|
inline |
Definition at line 226 of file composite_writer.h.
Referenced by main().

| std::unique_ptr< filtered_writer > kcenon::logger::make_filtered_writer | ( | std::unique_ptr< log_writer_interface > | writer, |
| std::unique_ptr< log_filter_interface > | filter ) |
Factory function to create a filtered writer.
| writer | The writer to wrap |
| filter | The filter to apply |
| std::invalid_argument | if writer is nullptr |
Definition at line 47 of file filtered_writer.cpp.
| std::unique_ptr< formatted_writer > kcenon::logger::make_formatted_writer | ( | std::unique_ptr< log_writer_interface > | writer, |
| std::unique_ptr< log_formatter_interface > | formatter ) |
Factory function to create a formatted writer.
| writer | The writer to wrap |
| formatter | The formatter to apply |
| std::invalid_argument | if writer is nullptr |
Definition at line 55 of file formatted_writer.cpp.
|
inline |
Definition at line 506 of file error_codes.h.
References logger_error_to_string().
Referenced by kcenon::logger::encrypted_writer::auto_rotate_key_if_needed(), kcenon::logger::utils::check_condition(), kcenon::logger::utils::check_file_exists(), kcenon::logger::utils::check_stream_state(), kcenon::logger::logger::enable_metrics_collection(), kcenon::logger::encrypted_writer::encrypt_data(), kcenon::logger::utils::ensure_directory_exists(), kcenon::logger::async_writer::flush(), kcenon::logger::console_writer::flush(), kcenon::logger::file_sink::flush(), kcenon::logger::network_writer::flush(), kcenon::logger::encrypted_writer::generate_iv(), kcenon::logger::async_writer::handle_overflow(), kcenon::logger::queued_writer_base< Container >::handle_overflow(), kcenon::logger::thread_system_monitor_adapter::reset_metrics(), kcenon::logger::encrypted_writer::rotate_key(), kcenon::logger::security::secure_key_storage::save_key(), kcenon::logger::utils::file_utils::set_file_permissions(), kcenon::logger::utils::try_write_operation(), kcenon::logger::logger_config::validate(), kcenon::logger::security::path_validator::validate(), kcenon::logger::security::secure_key_storage::validate_key_path(), kcenon::logger::utils::file_utils::validate_log_path(), kcenon::logger::batch_writer::write(), kcenon::logger::encrypted_writer::write(), kcenon::logger::file_writer::write(), kcenon::logger::rotating_file_writer::write(), kcenon::logger::async::high_performance_async_writer::write_direct(), and kcenon::logger::file_sink::write_raw().


|
inline |
Definition at line 526 of file error_codes.h.
References kcenon::common::ok().

|
inline |
Convert metric type to string.
| type | The metric type |
Definition at line 304 of file monitoring_interface.h.
|
constexprnoexcept |
Get string representation of writer category.
| cat | Writer category |
Definition at line 294 of file writer_category.h.
References asynchronous, composite, decorator, and synchronous.
|
inlineconstexpr |
Definition at line 171 of file writer_category.h.
Referenced by get_writer_category().
|
inlineconstexpr |
Definition at line 195 of file writer_category.h.
Referenced by get_writer_category().
|
inlineconstexpr |
Definition at line 183 of file writer_category.h.
Referenced by get_writer_category().
|
inlineconstexpr |
Definition at line 159 of file writer_category.h.
Referenced by get_writer_category().