Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
kcenon::logger::compact_formatter Class Reference

Compact formatter for minimal output. More...

#include <base_formatter.h>

Inheritance diagram for kcenon::logger::compact_formatter:
Inheritance graph
Collaboration diagram for kcenon::logger::compact_formatter:
Collaboration graph

Public Member Functions

std::string format (const log_entry &entry) const override
 Format a log entry into a string.
 
std::string get_format_type () const override
 
- Public Member Functions inherited from kcenon::logger::base_formatter
virtual ~base_formatter ()=default
 
- 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.
 
virtual std::string get_name () const =0
 

Additional Inherited Members

- Protected Member Functions inherited from kcenon::logger::base_formatter
std::string level_to_string (log_level level) const
 Convert log level to string.
 
std::string format_timestamp (const std::chrono::system_clock::time_point &timestamp) const
 Format timestamp to ISO8601 string.
 
std::string get_thread_id () const
 Get current thread ID as string.
 
- Protected Attributes inherited from kcenon::logger::log_formatter_interface
format_options options_
 

Detailed Description

Compact formatter for minimal output.

Definition at line 182 of file base_formatter.h.

Member Function Documentation

◆ format()

std::string kcenon::logger::compact_formatter::format ( const log_entry & entry) const
inlineoverridevirtual

Format a log entry into a string.

Parameters
entryThe log entry to format
Returns
Formatted string representation

Implements kcenon::logger::base_formatter.

Definition at line 184 of file base_formatter.h.

184 {
185 std::ostringstream oss;
186
187 // Ultra-compact format: LEVEL|MESSAGE
188 oss << level_to_string(entry.level)[0] << "|" << entry.message.to_string();
189
190 return oss.str();
191 }
std::string level_to_string(log_level level) const
Convert log level to string.

References kcenon::logger::log_entry::level, kcenon::logger::base_formatter::level_to_string(), kcenon::logger::log_entry::message, and kcenon::logger::small_string< SSO_SIZE >::to_string().

Here is the call graph for this function:

◆ get_format_type()

std::string kcenon::logger::compact_formatter::get_format_type ( ) const
inlineoverride

Definition at line 193 of file base_formatter.h.

193 {
194 return "compact";
195 }

The documentation for this class was generated from the following file: