mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-06-01 01:54:00 +00:00
update logging to use logger channel
This commit is contained in:
@@ -1,65 +1,73 @@
|
||||
/**
|
||||
* @file services/logging/log_entry.h
|
||||
* @brief POD log entry structure for asynchronous pipeline logging.
|
||||
* @brief Structured log record shared by the pipeline logging infra.
|
||||
*
|
||||
* Intent: Lightweight, move-safe data transfer between logging producer
|
||||
* (ChannelLogger) and consumer (LogConsumer) via BoundedChannel<LogEntry>.
|
||||
* LogEntry is a lightweight value type that can be passed safely between the
|
||||
* logging producer and dispatcher through BoundedChannel<LogEntry>.
|
||||
*/
|
||||
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_ENTRY_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_ENTRY_H_
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @enum LogLevel
|
||||
* @brief Severity levels for log entries.
|
||||
* @brief Severity levels supported by the logging infra.
|
||||
*/
|
||||
enum class LogLevel {
|
||||
Debug, ///< Development/debugging information.
|
||||
Info, ///< General informational messages.
|
||||
Warn, ///< Warning conditions.
|
||||
Error, ///< Error conditions.
|
||||
Debug, ///< Development/debugging information.
|
||||
Info, ///< General informational messages.
|
||||
Warn, ///< Warning conditions.
|
||||
Error, ///< Error conditions.
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum PipelinePhase
|
||||
* @brief Execution phases for contextual logging.
|
||||
* @brief Pipeline execution phases used to tag log records.
|
||||
*
|
||||
* Used to tag log entries by their processing stage, enabling phase-specific
|
||||
* analysis and filtering of the execution timeline.
|
||||
* The phase tag makes it easier to correlate log output with the part of the
|
||||
* pipeline that emitted it.
|
||||
*/
|
||||
enum class PipelinePhase {
|
||||
Startup, ///< Initialization and validation.
|
||||
UserGeneration, ///< User profile generation.
|
||||
BreweryAndBeerGeneration, ///< Brewery and beer data generation.
|
||||
CheckinGeneration, ///< Checkin (visit) record generation.
|
||||
RatingGeneration, ///< Rating and review generation.
|
||||
FollowGeneration, ///< Follow relationship generation.
|
||||
Teardown, ///< Finalization and cleanup.
|
||||
Startup, ///< Initialization and validation.
|
||||
UserGeneration, ///< User profile generation.
|
||||
BreweryAndBeerGeneration, ///< Brewery and beer data generation.
|
||||
CheckinGeneration, ///< Checkin (visit) record generation.
|
||||
RatingGeneration, ///< Rating and review generation.
|
||||
FollowGeneration, ///< Follow relationship generation.
|
||||
Teardown, ///< Finalization and cleanup.
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct LogEntry
|
||||
* @brief Single log event for asynchronous processing.
|
||||
* @brief Single structured log event.
|
||||
*
|
||||
* All fields are value types, allowing safe move semantics across
|
||||
* BoundedChannel without shared ownership or synchronization overhead.
|
||||
* All fields are value types, which keeps transfer across the bounded channel
|
||||
* simple and avoids shared ownership.
|
||||
*/
|
||||
struct LogEntry {
|
||||
/// @brief Timestamp when entry was created.
|
||||
std::chrono::system_clock::time_point timestamp =
|
||||
std::chrono::system_clock::now();
|
||||
/// @brief Timestamp when the entry was created.
|
||||
std::chrono::system_clock::time_point timestamp =
|
||||
std::chrono::system_clock::now();
|
||||
|
||||
/// @brief Severity level of this entry.
|
||||
LogLevel level;
|
||||
std::thread::id calling_thread_id;
|
||||
|
||||
/// @brief Pipeline phase when entry was logged.
|
||||
PipelinePhase phase;
|
||||
/// @brief The thread id of the logger
|
||||
std::thread::id logging_thread_id =
|
||||
std::this_thread::get_id(); // captured on construction
|
||||
|
||||
/// @brief Severity level of this entry.
|
||||
LogLevel level;
|
||||
|
||||
/// @brief Pipeline phase associated with the entry.
|
||||
PipelinePhase phase;
|
||||
|
||||
/// @brief Log message text.
|
||||
std::string message;
|
||||
|
||||
/// @brief Log message text.
|
||||
std::string message;
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_ENTRY_H_
|
||||
Reference in New Issue
Block a user