mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-05-31 17:53:59 +00:00
* Update class diagrams * Implement BoundedChannel and multithreaded logging infra * Integrate logging channel system * Update string concatenations to use std::format * Add pretty print log
89 lines
2.5 KiB
C++
89 lines
2.5 KiB
C++
/**
|
|
* @file services/logging/log_entry.h
|
|
* @brief Structured log record shared by the pipeline logging infra.
|
|
*
|
|
* 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 <source_location>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <vector>
|
|
|
|
/**
|
|
* @enum LogLevel
|
|
* @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.
|
|
};
|
|
|
|
/**
|
|
* @enum PipelinePhase
|
|
* @brief Pipeline execution phases used to tag log records.
|
|
*
|
|
* 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.
|
|
};
|
|
|
|
/**
|
|
* @struct LogDTO
|
|
* @brief User-provided subset of log fields. Used to capture call-site info transparently.
|
|
*/
|
|
struct LogDTO {
|
|
LogLevel level;
|
|
PipelinePhase phase;
|
|
std::string message;
|
|
};
|
|
|
|
/**
|
|
* @struct LogEntry
|
|
* @brief Single structured log event.
|
|
*
|
|
* All fields are value types, which keeps transfer across the bounded channel
|
|
* simple and avoids shared ownership.
|
|
*
|
|
* NOTE: timestamp, thread_id, and origin must be populated by ILogger::Log()
|
|
* before the entry is dispatched.
|
|
*/
|
|
struct LogEntry {
|
|
/// @brief Timestamp when the entry was created.
|
|
std::chrono::system_clock::time_point timestamp{};
|
|
|
|
/// @brief Source location where the log call was made.
|
|
std::source_location origin{};
|
|
|
|
/// @brief Thread responsible for emitting the log.
|
|
std::thread::id thread_id{};
|
|
|
|
|
|
/// @brief Severity level of this entry.
|
|
LogLevel level;
|
|
|
|
/// @brief Pipeline phase associated with the entry.
|
|
PipelinePhase phase;
|
|
|
|
/// @brief Log message text.
|
|
std::string message;
|
|
|
|
};
|
|
|
|
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_LOGGING_LOG_ENTRY_H_
|