Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
log_formatter_interface.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
5#pragma once
6
19#include <string>
20#include <memory>
21#include <functional>
22
23namespace kcenon::logger {
24
25// Forward declaration
26struct log_entry;
27
40 bool include_timestamp = true;
41
43 bool include_thread_id = true;
44
47
49 bool use_colors = false;
50
52 bool include_level = true;
53
55 bool pretty_print = false;
56};
57
74public:
75 virtual ~log_formatter_interface() = default;
76
91 virtual std::string format(const log_entry& entry) const = 0;
92
104 virtual void set_options(const format_options& opts) {
105 options_ = opts;
106 }
107
114 virtual format_options get_options() const {
115 return options_;
116 }
117
129 virtual std::string get_name() const = 0;
130
131protected:
134};
135
144using formatter_factory = std::function<std::unique_ptr<log_formatter_interface>()>;
145
146} // namespace kcenon::logger
Factory for creating log formatter instances.
Abstract interface for log message formatters.
virtual std::string format(const log_entry &entry) const =0
Format a log entry to a string.
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
Configuration options for log formatting.
Represents a single log entry with all associated metadata.
Definition log_entry.h:155