|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Formatter that outputs logfmt-structured log messages. More...
#include <logfmt_formatter.h>


Public Member Functions | |
| logfmt_formatter (const format_options &opts=format_options{}) | |
| Constructor with optional format options. | |
| std::string | format (const log_entry &entry) const override |
| Format a log entry to logfmt string. | |
| std::string | get_name () const override |
| Get formatter name. | |
Public Member Functions inherited from kcenon::logger::log_formatter_interface | |
| virtual | ~log_formatter_interface ()=default |
| virtual void | set_options (const format_options &opts) |
| Set formatting options. | |
| virtual format_options | get_options () const |
| Get current formatting options. | |
Static Private Member Functions | |
| static std::string | level_to_lowercase (log_level level) |
| Convert log level to lowercase string. | |
| static std::string | escape_logfmt_key (const std::string &key) |
| Escape a logfmt key (remove spaces and special characters) | |
| static std::string | escape_logfmt_value (const std::string &value) |
| Escape a logfmt value. | |
| static void | format_value (std::ostringstream &oss, const log_value &value) |
| Format a log_value to logfmt. | |
Additional Inherited Members | |
Protected Attributes inherited from kcenon::logger::log_formatter_interface | |
| format_options | options_ |
Formatter that outputs logfmt-structured log messages.
Produces machine-readable logfmt output suitable for log aggregation, analysis tools, and automated processing. The format consists of key=value pairs separated by spaces.
Features:
Thread-safety: This formatter is stateless and thread-safe.
Definition at line 68 of file logfmt_formatter.h.
|
inlineexplicit |
Constructor with optional format options.
| opts | Initial format options |
Definition at line 78 of file logfmt_formatter.h.
|
inlinestaticprivate |
Escape a logfmt key (remove spaces and special characters)
| key | Key to escape |
Definition at line 217 of file logfmt_formatter.h.
Referenced by format().

|
inlinestaticprivate |
Escape a logfmt value.
| value | Value to escape |
Values containing spaces, quotes, or special characters are wrapped in double quotes with proper escaping.
Definition at line 238 of file logfmt_formatter.h.
Referenced by format(), and format_value().

|
inlinenodiscardoverridevirtual |
Format a log entry to logfmt string.
| entry | The log entry to format |
Produces key=value pairs with fields:
Implements kcenon::logger::log_formatter_interface.
Definition at line 103 of file logfmt_formatter.h.
References kcenon::logger::log_entry::category, escape_logfmt_key(), escape_logfmt_value(), kcenon::logger::log_entry::fields, kcenon::logger::utils::time_utils::format_iso8601(), format_value(), kcenon::logger::format_options::include_level, kcenon::logger::format_options::include_source_location, kcenon::logger::format_options::include_thread_id, kcenon::logger::format_options::include_timestamp, kcenon::logger::log_entry::level, level_to_lowercase(), kcenon::logger::log_entry::location, kcenon::logger::log_entry::message, kcenon::logger::log_formatter_interface::options_, kcenon::logger::log_entry::otel_ctx, kcenon::logger::log_entry::thread_id, kcenon::logger::log_entry::timestamp, and kcenon::logger::small_string< SSO_SIZE >::to_string().
Referenced by logfmt_formatter_example().


|
inlinestaticprivate |
Format a log_value to logfmt.
| oss | Output stream |
| value | Value to format |
Definition at line 274 of file logfmt_formatter.h.
References escape_logfmt_value().
Referenced by format().


|
inlinenodiscardoverridevirtual |
Get formatter name.
Implements kcenon::logger::log_formatter_interface.
Definition at line 189 of file logfmt_formatter.h.
|
inlinestaticprivate |
Convert log level to lowercase string.
| level | Log level |
Definition at line 199 of file logfmt_formatter.h.
Referenced by format().
