9 #include "quill/backend/BackendManager.h" 10 #include "quill/backend/BackendOptions.h" 11 #include "quill/backend/SignalHandler.h" 12 #include "quill/core/Attributes.h" 13 #include "quill/core/QuillError.h" 24 constexpr uint32_t VersionMajor{10};
25 constexpr uint32_t VersionMinor{0};
26 constexpr uint32_t VersionPatch{1};
27 constexpr uint32_t Version{VersionMajor * 10000 + VersionMinor * 100 + VersionPatch};
38 std::call_once(detail::BackendManager::instance().get_start_once_flag(),
42 detail::BackendManager::instance().start_backend_thread(options);
47 std::atexit([]() { detail::BackendManager::instance().stop_backend_thread(); });
70 template <
typename TFrontendOptions>
74 std::call_once(detail::BackendManager::instance().get_start_once_flag(),
75 [backend_options, signal_handler_options]()
78 detail::init_exception_handler<TFrontendOptions>();
85 sigprocmask(SIG_SETMASK, &
set, &oldset);
86 detail::init_signal_handler<TFrontendOptions>(signal_handler_options.
catchable_signals);
90 detail::BackendManager::instance().start_backend_thread(backend_options);
92 detail::SignalHandlerContext::instance().logger_name = signal_handler_options.
logger;
94 detail::SignalHandlerContext::instance().signal_handler_timeout_seconds.store(
98 detail::SignalHandlerContext::instance().backend_thread_id.store(
99 detail::BackendManager::instance().get_backend_thread_id());
105 sigprocmask(SIG_SETMASK, &oldset,
nullptr);
111 std::atexit([]() { detail::BackendManager::instance().stop_backend_thread(); });
119 QUILL_ATTRIBUTE_COLD
static void stop() noexcept
121 detail::BackendManager::instance().stop_backend_thread();
131 static void notify() noexcept { detail::BackendManager::instance().notify_backend_thread(); }
139 return detail::BackendManager::instance().is_backend_thread_running();
148 return detail::BackendManager::instance().get_backend_thread_id();
163 return detail::BackendManager::instance().convert_rdtsc_to_epoch_time(rdtsc_value);
209 detail::BackendManager::instance().get_start_once_flag(), [&manual_backend_worker]()
mutable 210 { manual_backend_worker = detail::BackendManager::instance().get_manual_backend_worker(); });
212 if (!manual_backend_worker)
215 QuillError{
"acquire_manual_backend_worker() can only be called once per process. " 216 "Additionally, it should not be " 217 "called when start() has already been invoked"});
220 return manual_backend_worker;
static QUILL_NODISCARD uint32_t get_thread_id() noexcept
Retrieves the ID of the backend thread.
Definition: Backend.h:146
static QUILL_NODISCARD bool is_running() noexcept
Checks if the backend is currently running.
Definition: Backend.h:137
static QUILL_ATTRIBUTE_COLD void start(BackendOptions const &backend_options, SignalHandlerOptions const &signal_handler_options)
Starts the backend thread and initialises a signal handler.
Definition: Backend.h:71
uint32_t timeout_seconds
Defines the timeout duration in seconds for the signal handler alarm.
Definition: SignalHandler.h:62
static void notify() noexcept
Notifies the backend thread to wake up.
Definition: Backend.h:131
static QUILL_NODISCARD uint64_t convert_rdtsc_to_epoch_time(uint64_t rdtsc_value) noexcept
Converts an rdtsc value to epoch time.
Definition: Backend.h:161
std::string logger
The logger instance that the signal handler will use to log errors when the application crashes...
Definition: SignalHandler.h:71
static QUILL_ATTRIBUTE_COLD ManualBackendWorker * acquire_manual_backend_worker()
This feature is designed for advanced users who need to run the backend worker on their own thread...
Definition: Backend.h:204
This class can be used when you want to run the backend worker on your own thread.
Definition: ManualBackendWorker.h:20
static QUILL_ATTRIBUTE_COLD void start(BackendOptions const &options=BackendOptions{})
Starts the backend thread.
Definition: Backend.h:36
custom exception
Definition: QuillError.h:45
std::vector< int > catchable_signals
List of signals that the backend should catch if with_signal_handler is enabled.
Definition: SignalHandler.h:53
Struct to hold options for the signal handler.
Definition: SignalHandler.h:48
static QUILL_ATTRIBUTE_COLD void stop() noexcept
Stops the backend thread.
Definition: Backend.h:119
Configuration options for the backend.
Definition: BackendOptions.h:30