quill
BackendOptions.h
1 
7 #pragma once
8 
9 #include "quill/core/Attributes.h"
10 
11 #include <array>
12 #include <chrono>
13 #include <cstdint>
14 #include <cstdio>
15 #include <functional>
16 #include <limits>
17 #include <string>
18 
19 #if defined(__MINGW32__)
20  #include <iostream>
21 #endif
22 
23 QUILL_BEGIN_NAMESPACE
24 
31 {
36  std::string thread_name = "QuillBackend";
37 
44  bool enable_yield_when_idle = false;
45 
49  std::chrono::nanoseconds sleep_duration = std::chrono::microseconds{100};
50 
59 
76 
92  size_t transit_events_hard_limit = 65'536;
93 
132  std::chrono::microseconds log_timestamp_ordering_grace_period{5};
133 
145  bool wait_for_queues_to_empty_before_exit = true;
146 
154  uint16_t cpu_affinity = (std::numeric_limits<uint16_t>::max)();
155 
170  std::function<void(std::string const&)> error_notifier = [](std::string const& error_message)
171  {
172 #if !defined(__MINGW32__)
173  std::fprintf(stderr, "%s\n", error_message.data());
174 #else
175  // fprintf crashes on mingw gcc 13 for unknown reason
176  std::cerr << error_message.data() << "\n";
177 #endif
178  };
179 
185  std::function<void()> backend_worker_on_poll_begin = {};
186 
192  std::function<void()> backend_worker_on_poll_end = {};
193 
207  std::chrono::milliseconds rdtsc_resync_interval = std::chrono::milliseconds{500};
208 
224  std::chrono::milliseconds sink_min_flush_interval = std::chrono::milliseconds{200};
225 
239  std::function<bool(char c)> check_printable_char = [](char c)
240  { return (c >= ' ' && c <= '~') || (c == '\n') || (c == '\t') || (c == '\r'); };
241 
247  std::array<std::string, 11> log_level_descriptions = {
248  "TRACE_L3", "TRACE_L2", "TRACE_L1", "DEBUG", "INFO", "NOTICE",
249  "WARNING", "ERROR", "CRITICAL", "BACKTRACE", "NONE"};
250 
257  std::array<std::string, 11> log_level_short_codes = {"T3", "T2", "T1", "D", "I", "N",
258  "W", "E", "C", "BT", "_"};
259 
280  bool check_backend_singleton_instance = true;
281 };
282 
283 QUILL_END_NAMESPACE
bool enable_yield_when_idle
The backend employs "busy-waiting" by spinning around each frontend thread&#39;s queue.
Definition: BackendOptions.h:44
uint32_t transit_event_buffer_initial_capacity
The backend pops all log messages from the frontend queues and buffers them in a local ring buffer qu...
Definition: BackendOptions.h:58
std::chrono::nanoseconds sleep_duration
Specifies the duration the backend sleeps if there is no remaining work to process in the queues...
Definition: BackendOptions.h:49
size_t transit_events_hard_limit
The backend gives priority to reading messages from the frontend queues and temporarily buffers them...
Definition: BackendOptions.h:92
size_t transit_events_soft_limit
The backend gives priority to reading messages from the frontend queues of all the hot threads and te...
Definition: BackendOptions.h:75
std::string thread_name
The name assigned to the backend, visible during thread naming queries (e.g., pthread_getname_np) or ...
Definition: BackendOptions.h:36
Configuration options for the backend.
Definition: BackendOptions.h:30