Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
template_formatter.h File Reference

Template-based customizable formatter for structured logging kcenon. More...

#include "../interfaces/log_entry.h"
#include "../interfaces/log_formatter_interface.h"
#include "../utils/time_utils.h"
#include "../utils/string_utils.h"
#include <sstream>
#include <iomanip>
#include <vector>
#include <type_traits>
#include <variant>
#include <kcenon/common/interfaces/logger_interface.h>
Include dependency graph for template_formatter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  kcenon::logger::template_formatter
 Customizable formatter using template strings with placeholders. More...
 
struct  kcenon::logger::template_formatter::template_segment
 Segment of parsed template. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::logger
 

Detailed Description

Template-based customizable formatter for structured logging kcenon.

Since
3.1.0

Formats log messages using user-defined templates with placeholders. Placeholders are replaced with actual log entry values at runtime.

Supported placeholders:

  • {timestamp} - ISO 8601 formatted timestamp
  • {timestamp_local} - Local time formatted timestamp
  • {level} - Log level (e.g., "INFO", "ERROR")
  • {level_lower} - Lowercase log level (e.g., "info", "error")
  • {message} - Log message content
  • {thread_id} - Thread identifier
  • {file} - Source file path
  • {filename} - Source file name only (without path)
  • {line} - Source line number
  • {function} - Function name
  • {category} - Log category
  • {trace_id} - OpenTelemetry trace ID
  • {span_id} - OpenTelemetry span ID

Definition in file template_formatter.h.