Class thl::Logger::rt::Queue#
-
class Queue#
A bounded lock-free queue of log records with real-time safe producers.
Public Functions
-
explicit Queue(std::size_t capacity = k_queue_capacity)#
- Parameters:
capacity – Number of records; rounded up to a power of two (min 2). The slots are allocated here and never again.
-
~Queue()#
-
Status logf(LogLevel level, const char *group, const char *fmt, ...) noexcept#
printf-style real-time logging.
Formatting uses thl::core::rt_vsnprintf, a locale-free subset of printf (see RtFormat.h for the supported conversions; the compiler checks the format string where it can).
-
Status logf(LogLevel level, std::uint32_t flags, const char *group, const char *fmt, ...) noexcept#
logf() with record flags (see “Record flags”):
flagsis copied into the record unchanged and reaches the sinks in LogRecord::m_flags.
-
Status vlogf(LogLevel level, const char *group, const char *fmt, va_list args) noexcept#
va_list variant of logf().
-
Status vlogf(LogLevel level, std::uint32_t flags, const char *group, const char *fmt, va_list args) noexcept#
va_list variant of logf() with record flags.
-
Status log(LogLevel level, const char *group, const char *message) noexcept#
Real-time logging of a preformatted message.
-
Status log(LogLevel level, std::uint32_t flags, const char *group, const char *message) noexcept#
log() with record flags.
-
std::size_t drain()#
Forward every queued record to the sinks on the calling thread and report drops.
Returns the number of records delivered. Not real-time safe.
Every record dispatched here carries k_flag_realtime (in addition to its own flags) and source “rt”. Drops are reported exactly once: the pass takes the drop counter first and puts it into LogRecord::m_dropped_before of the first record it dispatches; every other record of the pass carries 0. Only when the pass has no record to deliver does it dispatch one synthetic Warning record (group “thl.logger”, message “real-time log queue overflowed”) that carries the count instead. Drops that happen while the pass runs are reported by the next pass. The count says how many records were lost before this one was delivered, not where in the stream the gap lies.
-
void set_accepting(bool accepting) noexcept#
While false, logf()/log() return NoConsumer without formatting.
A queue starts accepting; owners that have no consumer yet may switch it off.
-
bool is_accepting() const noexcept#
-
std::uint64_t dropped_count() const noexcept#
Records dropped because the queue was full, since the last drain().
-
std::size_t capacity() const noexcept#
-
explicit Queue(std::size_t capacity = k_queue_capacity)#