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

Configuration strategy for performance tuning. More...

#include <performance_strategy.h>

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

Public Member Functions

 performance_strategy (performance_level level)
 Constructor with performance level.
 
std::string get_name () const override
 Get the strategy name.
 
void apply (logger_config &config) const override
 Apply this strategy to a logger configuration.
 
int priority () const override
 Get the strategy priority.
 
- Public Member Functions inherited from kcenon::logger::config_strategy_interface
virtual ~config_strategy_interface ()=default
 
virtual bool is_applicable () const
 Check if this strategy is applicable in the current context.
 

Static Private Member Functions

static void apply_low_latency (logger_config &config)
 
static void apply_balanced (logger_config &config)
 
static void apply_high_throughput (logger_config &config)
 
static void apply_minimal_overhead (logger_config &config)
 
static std::string level_to_string (performance_level level)
 

Private Attributes

performance_level level_
 

Detailed Description

Configuration strategy for performance tuning.

Applies performance-optimized settings based on the selected level. Each level is optimized for specific use cases.

Since
2.0.0

Definition at line 44 of file performance_strategy.h.

Constructor & Destructor Documentation

◆ performance_strategy()

kcenon::logger::performance_strategy::performance_strategy ( performance_level level)
inlineexplicit

Constructor with performance level.

Parameters
levelThe performance tuning level to apply

Definition at line 50 of file performance_strategy.h.

51 : level_(level) {}

Member Function Documentation

◆ apply()

void kcenon::logger::performance_strategy::apply ( logger_config & config) const
inlineoverridevirtual

Apply this strategy to a logger configuration.

Parameters
configThe configuration to modify

Modifies the provided configuration according to the strategy's rules. Changes are applied in-place.

Implements kcenon::logger::config_strategy_interface.

Definition at line 57 of file performance_strategy.h.

57 {
58 switch (level_) {
60 apply_low_latency(config);
61 break;
63 apply_balanced(config);
64 break;
67 break;
70 break;
71 }
72 }
static void apply_balanced(logger_config &config)
static void apply_low_latency(logger_config &config)
static void apply_minimal_overhead(logger_config &config)
static void apply_high_throughput(logger_config &config)
@ high_throughput
Maximize throughput (large buffers, batch processing)
@ minimal_overhead
Minimize resource usage (simple format, less features)
@ low_latency
Minimize latency (small buffers, immediate flush)
@ balanced
Balanced configuration (default)

References apply_balanced(), apply_high_throughput(), apply_low_latency(), apply_minimal_overhead(), kcenon::logger::balanced, kcenon::logger::high_throughput, level_, kcenon::logger::low_latency, and kcenon::logger::minimal_overhead.

Here is the call graph for this function:

◆ apply_balanced()

static void kcenon::logger::performance_strategy::apply_balanced ( logger_config & config)
inlinestaticprivate

Definition at line 92 of file performance_strategy.h.

92 {
93 config.async = true;
94 config.buffer_size = 8192;
95 config.batch_size = 100;
96 config.flush_interval = std::chrono::milliseconds(1000);
97 config.use_lock_free = false;
98 config.max_queue_size = 10000;
99 config.queue_overflow_policy = logger_config::overflow_policy::drop_newest;
100 config.enable_batch_writing = true;
101 }

References kcenon::logger::logger_config::async, kcenon::logger::logger_config::batch_size, kcenon::logger::logger_config::buffer_size, kcenon::logger::logger_config::enable_batch_writing, kcenon::logger::logger_config::flush_interval, kcenon::logger::logger_config::max_queue_size, kcenon::logger::logger_config::queue_overflow_policy, and kcenon::logger::logger_config::use_lock_free.

Referenced by apply().

Here is the caller graph for this function:

◆ apply_high_throughput()

static void kcenon::logger::performance_strategy::apply_high_throughput ( logger_config & config)
inlinestaticprivate

Definition at line 103 of file performance_strategy.h.

103 {
104 config.async = true;
105 config.buffer_size = 65536;
106 config.batch_size = 500;
107 config.flush_interval = std::chrono::milliseconds(5000);
108 config.use_lock_free = true;
109 config.max_queue_size = 100000;
110 config.queue_overflow_policy = logger_config::overflow_policy::drop_oldest;
111 config.writer_thread_count = 2;
112 config.enable_compression = true;
113 config.enable_batch_writing = true;
114 }

References kcenon::logger::logger_config::async, kcenon::logger::logger_config::batch_size, kcenon::logger::logger_config::buffer_size, kcenon::logger::logger_config::enable_batch_writing, kcenon::logger::logger_config::enable_compression, kcenon::logger::logger_config::flush_interval, kcenon::logger::logger_config::max_queue_size, kcenon::logger::logger_config::queue_overflow_policy, kcenon::logger::logger_config::use_lock_free, and kcenon::logger::logger_config::writer_thread_count.

Referenced by apply().

Here is the caller graph for this function:

◆ apply_low_latency()

static void kcenon::logger::performance_strategy::apply_low_latency ( logger_config & config)
inlinestaticprivate

Definition at line 81 of file performance_strategy.h.

81 {
82 config.async = true;
83 config.buffer_size = 4096;
84 config.batch_size = 10;
85 config.flush_interval = std::chrono::milliseconds(10);
86 config.use_lock_free = true;
87 config.max_queue_size = 10000;
88 config.queue_overflow_policy = logger_config::overflow_policy::drop_oldest;
89 config.enable_batch_writing = false;
90 }

References kcenon::logger::logger_config::async, kcenon::logger::logger_config::batch_size, kcenon::logger::logger_config::buffer_size, kcenon::logger::logger_config::enable_batch_writing, kcenon::logger::logger_config::flush_interval, kcenon::logger::logger_config::max_queue_size, kcenon::logger::logger_config::queue_overflow_policy, and kcenon::logger::logger_config::use_lock_free.

Referenced by apply().

Here is the caller graph for this function:

◆ apply_minimal_overhead()

static void kcenon::logger::performance_strategy::apply_minimal_overhead ( logger_config & config)
inlinestaticprivate

Definition at line 116 of file performance_strategy.h.

116 {
117 config.async = true;
118 config.buffer_size = 4096;
119 config.batch_size = 50;
120 config.flush_interval = std::chrono::milliseconds(2000);
121 config.enable_metrics = false;
122 config.enable_structured_logging = false;
123 config.enable_source_location = false;
124 config.enable_color_output = false;
125 config.enable_batch_writing = true;
126 }

References kcenon::logger::logger_config::async, kcenon::logger::logger_config::batch_size, kcenon::logger::logger_config::buffer_size, kcenon::logger::logger_config::enable_batch_writing, kcenon::logger::logger_config::enable_color_output, kcenon::logger::logger_config::enable_metrics, kcenon::logger::logger_config::enable_source_location, kcenon::logger::logger_config::enable_structured_logging, and kcenon::logger::logger_config::flush_interval.

Referenced by apply().

Here is the caller graph for this function:

◆ get_name()

std::string kcenon::logger::performance_strategy::get_name ( ) const
inlineoverridevirtual

Get the strategy name.

Returns
Human-readable strategy name

Implements kcenon::logger::config_strategy_interface.

Definition at line 53 of file performance_strategy.h.

53 {
54 return "performance:" + level_to_string(level_);
55 }
static std::string level_to_string(performance_level level)

References level_, and level_to_string().

Here is the call graph for this function:

◆ level_to_string()

static std::string kcenon::logger::performance_strategy::level_to_string ( performance_level level)
inlinestaticprivate

Definition at line 128 of file performance_strategy.h.

128 {
129 switch (level) {
130 case performance_level::low_latency: return "low_latency";
131 case performance_level::balanced: return "balanced";
132 case performance_level::high_throughput: return "high_throughput";
133 case performance_level::minimal_overhead: return "minimal_overhead";
134 default: return "unknown";
135 }
136 }

References kcenon::logger::balanced, kcenon::logger::high_throughput, kcenon::logger::low_latency, and kcenon::logger::minimal_overhead.

Referenced by get_name().

Here is the caller graph for this function:

◆ priority()

int kcenon::logger::performance_strategy::priority ( ) const
inlineoverridevirtual

Get the strategy priority.

Returns
Priority value (higher = applied first)

When multiple strategies are applied, they are sorted by priority (descending) before application.

Reimplemented from kcenon::logger::config_strategy_interface.

Definition at line 74 of file performance_strategy.h.

74 {
75 return 50; // Medium priority
76 }

Member Data Documentation

◆ level_

performance_level kcenon::logger::performance_strategy::level_
private

Definition at line 79 of file performance_strategy.h.

Referenced by apply(), and get_name().


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