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

Represents a single log entry with all associated metadata. More...

#include <log_entry.h>

Collaboration diagram for kcenon::logger::log_entry:
Collaboration graph

Public Member Functions

 log_entry (log_level lvl, const std::string &msg, std::chrono::system_clock::time_point ts=std::chrono::system_clock::now())
 
 log_entry (log_level lvl, const std::string &msg, const std::string &file, int line, const std::string &function, std::chrono::system_clock::time_point ts=std::chrono::system_clock::now())
 
 log_entry (log_entry &&) noexcept=default
 Move constructor.
 
log_entryoperator= (log_entry &&) noexcept=default
 Move assignment operator.
 
 log_entry (const log_entry &)=delete
 Deleted copy constructor.
 
log_entryoperator= (const log_entry &)=delete
 Deleted copy assignment operator.
 

Public Attributes

log_level level
 Severity level of the log message.
 
small_string_256 message
 The actual log message.
 
std::chrono::system_clock::time_point timestamp
 Timestamp when the log entry was created.
 
std::optional< source_locationlocation
 Optional source code location information.
 
std::optional< small_string_64thread_id
 Optional thread identifier.
 
std::optional< small_string_128category
 Optional category for log filtering and routing.
 
std::optional< otlp::otel_contextotel_ctx
 Optional OpenTelemetry context for trace correlation.
 
std::optional< log_fieldsfields
 Optional structured fields for key-value logging.
 

Detailed Description

Represents a single log entry with all associated metadata.

The log_entry structure is the core data type that flows through the logging system. It contains the log message, severity level, timestamp, and optional metadata such as source location and thread information.

The structure is designed for high performance:

  • Move-only semantics to avoid copying
  • Small string optimization for common string sizes
  • Optional fields to minimize memory usage
Note
This structure is move-only. Use std::move() when passing log entries to avoid compilation errors.
Warning
Copy operations are explicitly deleted to prevent performance degradation from accidental copies in high-throughput scenarios.
Since
1.0.0
Examples
advanced_features_demo.cpp, composite_writer_example.cpp, custom_writer_example.cpp, decorator_usage.cpp, security_demo.cpp, structured_logging_example.cpp, and writer_builder_example.cpp.

Definition at line 155 of file log_entry.h.

Constructor & Destructor Documentation

◆ log_entry() [1/4]

kcenon::logger::log_entry::log_entry ( log_level lvl,
const std::string & msg,
std::chrono::system_clock::time_point ts = std::chrono::system_clock::now() )
inline
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/interfaces/log_entry.h.

Definition at line 231 of file log_entry.h.

234 : level(lvl), message(msg), timestamp(ts) {}
log_level level
Severity level of the log message.
Definition log_entry.h:162
small_string_256 message
The actual log message.
Definition log_entry.h:169
std::chrono::system_clock::time_point timestamp
Timestamp when the log entry was created.
Definition log_entry.h:175

◆ log_entry() [2/4]

kcenon::logger::log_entry::log_entry ( log_level lvl,
const std::string & msg,
const std::string & file,
int line,
const std::string & function,
std::chrono::system_clock::time_point ts = std::chrono::system_clock::now() )
inline

Definition at line 261 of file log_entry.h.

267 : level(lvl), message(msg), timestamp(ts),
268 location(source_location{file, line, function}) {}
std::optional< source_location > location
Optional source code location information.
Definition log_entry.h:183

◆ log_entry() [3/4]

kcenon::logger::log_entry::log_entry ( log_entry && )
defaultnoexcept

Move constructor.

Enables efficient transfer of log entries without copying

Since
1.0.0

◆ log_entry() [4/4]

kcenon::logger::log_entry::log_entry ( const log_entry & )
delete

Deleted copy constructor.

Prevents accidental copying for performance reasons

Since
1.0.0

Member Function Documentation

◆ operator=() [1/2]

log_entry & kcenon::logger::log_entry::operator= ( const log_entry & )
delete

Deleted copy assignment operator.

Prevents accidental copying for performance reasons

Since
1.0.0

◆ operator=() [2/2]

log_entry & kcenon::logger::log_entry::operator= ( log_entry && )
defaultnoexcept

Move assignment operator.

Enables efficient transfer of log entries without copying

Since
1.0.0
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/interfaces/log_entry.h.

Member Data Documentation

◆ category

std::optional<small_string_128> kcenon::logger::log_entry::category

◆ fields

◆ level

log_level kcenon::logger::log_entry::level

◆ location

◆ message

small_string_256 kcenon::logger::log_entry::message

◆ otel_ctx

std::optional<otlp::otel_context> kcenon::logger::log_entry::otel_ctx

◆ thread_id

std::optional<small_string_64> kcenon::logger::log_entry::thread_id

◆ timestamp


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