57 , flush_interval(1000)
58 , preserve_order(true) {}
67 const config& cfg = config{});
72 ~batch_writer()
override;
92 std::string get_name()
const override;
98 bool is_healthy()
const override;
104 size_t get_current_batch_size()
const;
110 std::atomic<uint64_t> total_batches{0};
111 std::atomic<uint64_t> total_entries{0};
112 std::atomic<uint64_t> dropped_entries{0};
113 std::atomic<uint64_t> flush_on_size{0};
114 std::atomic<uint64_t> flush_on_timeout{0};
115 std::atomic<uint64_t> manual_flushes{0};
118 return total_batches > 0 ?
119 static_cast<double>(total_entries) / total_batches : 0.0;
146 bool should_flush_by_size()
const;
152 bool should_flush_by_time()
const;
173 size_t batch_size = 100,
174 std::chrono::milliseconds flush_interval = std::chrono::milliseconds{1000});
Batch writer that accumulates log entries and writes them in batches.
std::chrono::steady_clock::time_point last_flush_time_
const batch_stats & get_stats() const
Get batch statistics.
Abstract base class for queue-based log writers.
DLL export/import macros for logger_system shared library support.
#define LOGGER_SYSTEM_API
std::unique_ptr< batch_writer > make_batch_writer(log_writer_ptr writer, size_t batch_size=100, std::chrono::milliseconds flush_interval=std::chrono::milliseconds{1000})
Factory function to create a batch writer.
std::unique_ptr< log_writer_interface > log_writer_ptr
Type alias for writer unique pointer.
Base template for queue-based log writers.
double average_batch_size() const
Configuration for batch writer.
std::chrono::milliseconds flush_interval