14 , wrapped_writer_(std::move(wrapped_writer)) {
17 throw std::invalid_argument(
"Wrapped writer cannot be null");
22 memory_pool_ = std::make_unique<memory::object_pool<memory::log_entry_pool::pooled_log_entry>>(
28 batch_processor_ = make_batch_processor(
29 log_writer_ptr(wrapped_writer_.release()),
30 config_.batch_config);
39 bool expected =
false;
40 if (!
running_.compare_exchange_strong(expected,
true)) {
65 const auto start_time = std::chrono::steady_clock::now();
67 if (!
running_.load(std::memory_order_relaxed)) {
76 auto level =
static_cast<common::interfaces::log_level
>(
static_cast<int>(entry.
level));
88 const auto end_time = std::chrono::steady_clock::now();
89 const auto latency = end_time - start_time;
113 if (!
running_.load(std::memory_order_relaxed)) {
126 return "high_perf_async_" + base_name;
139 return static_cast<double>(queue_size) / max_size;
157 const auto start_time = std::chrono::steady_clock::now();
159 const auto end_time = std::chrono::steady_clock::now();
161 const auto latency = end_time - start_time;
173 const double latency_us = std::chrono::duration_cast<std::chrono::microseconds>(latency).count();
174 const double alpha = 0.1;
176 const double new_avg = alpha * latency_us + (1.0 - alpha) * current_avg;
180 const auto now = std::chrono::steady_clock::now();
181 const auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(now -
stats_.
start_time).count();
184 const double throughput =
static_cast<double>(total_writes) / elapsed;
203 return std::make_unique<high_performance_async_writer>(std::move(writer), cfg);
bool use_color() const
Get current color output setting.
std::string to_string() const
Convert to std::string.
std::unique_ptr< high_performance_async_writer > make_high_performance_async_writer(log_writer_ptr writer, const high_performance_async_writer::config &cfg)
Factory function to create a high-performance async writer.
common::VoidResult make_logger_void_result(logger_error_code code, const std::string &message="")
std::unique_ptr< log_writer_interface > log_writer_ptr
Type alias for writer unique pointer.
Log entry optimized for high-performance queuing.
std::chrono::system_clock::time_point timestamp
common::interfaces::log_level level
Represents a single log entry with all associated metadata.
std::optional< source_location > location
Optional source code location information.
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.