update doxygen comments for concurrent logger

This commit is contained in:
Aaron Po
2026-05-14 21:21:28 -04:00
parent 74f11b57e2
commit a4968eb043
6 changed files with 161 additions and 88 deletions

View File

@@ -1,10 +1,10 @@
/**
* @file services/logging/log_consumer.h
* @brief Dedicated log drain worker for the pipeline logging channel.
* @brief Dedicated log consumer/drain for asynchronous pipeline logging.
*
* LogConsumer runs on its own thread, draining LogEntry items from a
* BoundedChannel<LogEntry> and forwarding them to spdlog. Exits cleanly
* when the channel is closed.
* Intent: Dequeue LogEntry values from a BoundedChannel on a dedicated thread
* and forward them to spdlog for I/O and formatting. Decouples application
* logic from logging latency.
*/
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_CONSUMER_H_
@@ -17,28 +17,43 @@
#include "concurrency/bounded_channel.h"
#include "services/logging/log_entry.h"
/**
* @class LogConsumer
* @brief Consumes log entries from channel and forwards to spdlog.
*
* Non-copyable, non-movable. Designed to run on its own dedicated std::thread.
* Drains the channel until closure, then exits cleanly.
*/
class LogConsumer {
public:
explicit LogConsumer(BoundedChannel<LogEntry>& channel);
/**
* @brief Construct a log consumer.
*
* @param channel Reference to bounded channel for log entry retrieval.
* Channel must outlive this consumer instance.
*/
explicit LogConsumer(BoundedChannel<LogEntry>& channel);
LogConsumer(const LogConsumer&) = delete;
LogConsumer& operator=(const LogConsumer&) = delete;
LogConsumer(LogConsumer&&) = delete;
LogConsumer& operator=(LogConsumer&&) = delete;
LogConsumer(const LogConsumer&) = delete;
LogConsumer& operator=(const LogConsumer&) = delete;
LogConsumer(LogConsumer&&) = delete;
LogConsumer& operator=(LogConsumer&&) = delete;
/**
* @brief Drains the channel until it is closed.
*
* Intended to be run on a dedicated std::thread. Exits when:
* - The channel is closed and the queue is fully drained.
*/
void Run();
/**
* @brief Main loop: drain channel and forward entries to spdlog.
*
* Intended to be called once on a dedicated thread. Returns when:
* - Channel is closed AND all queued entries are drained.
*
* Thread-safe for use from multiple ChannelLogger instances on other threads.
*/
void Run();
private:
BoundedChannel<LogEntry>& channel_;
BoundedChannel<LogEntry>& channel_;
static spdlog::level::level_enum ToSpdlogLevel(LogLevel level);
static std::string ToString(PipelinePhase phase);
static spdlog::level::level_enum ToSpdlogLevel(LogLevel level);
static std::string ToString(PipelinePhase phase);
};
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_CONSUMER_H_