mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-06-01 01:54:00 +00:00
Implement pipeline logging with bounded channels and orchestrator integration
This commit is contained in:
44
tooling/pipeline/includes/services/logging/log_consumer.h
Normal file
44
tooling/pipeline/includes/services/logging/log_consumer.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @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<LogEntry> 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 <spdlog/spdlog.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "concurrency/bounded_channel.h"
|
||||
#include "services/logging/log_entry.h"
|
||||
|
||||
class LogConsumer {
|
||||
public:
|
||||
explicit LogConsumer(BoundedChannel<LogEntry>& 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<LogEntry>& channel_;
|
||||
|
||||
static spdlog::level::level_enum ToSpdlogLevel(LogLevel level);
|
||||
static std::string ToString(PipelinePhase phase);
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_CONSUMER_H_
|
||||
Reference in New Issue
Block a user