/** * @file services/logging/log_consumer.h * @brief Dedicated log drain worker for the pipeline logging channel. * * LogConsumer runs on its own thread, draining LogEntry items from a * BoundedChannel and forwarding them to spdlog. Exits cleanly * when the channel is closed. */ #ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_CONSUMER_H_ #define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_CONSUMER_H_ #include #include #include "concurrency/bounded_channel.h" #include "services/logging/log_entry.h" class LogConsumer { public: explicit LogConsumer(BoundedChannel& channel); 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(); private: BoundedChannel& channel_; static spdlog::level::level_enum ToSpdlogLevel(LogLevel level); static std::string ToString(PipelinePhase phase); }; #endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_CONSUMER_H_