iceberg-cpp
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
iceberg::LogMessage Class Reference

A single log record handed to a Logger. More...

#include <logger.h>

Inheritance diagram for iceberg::LogMessage:

Public Member Functions

 Builder (LogLevel level, std::source_location location=std::source_location::current())
 
Builder & Message (std::string message)
 Set the already-formatted message text.
 
Builder & Attribute (std::string key, std::string value)
 Append a structured key/value attribute.
 
Builder & Location (std::source_location location)
 Override the record's source location (defaults to the build site).
 
LogMessage Build ()
 Materialize the LogMessage, moving the accumulated state out.
 

Public Attributes

LogLevel level = LogLevel::kOff
 
std::string message
 
std::source_location location = std::source_location::current()
 
std::vector< LogAttributeattributes
 

Detailed Description

A single log record handed to a Logger.

Fluent builder for LogMessage, the easy path to attach structured attributes.

The formatted message is owned (moved in by the logging macros), so a sink may safely retain the record beyond the Log() call. The member set must not depend on the build's logging backend (the spdlog backend never appears here). Use LogMessage::Builder for a readable way to assemble one, especially with structured attributes.

Example: auto record = LogMessage::Builder(LogLevel::kInfo) .Message("scan finished") .Attribute("table", table_name) .Attribute("snapshot_id", std::to_string(id)) .Build(); logger->Log(std::move(record));

The location defaults to the caller's construction site (captured via the constructor's default argument); override it with Location() (e.g. to forward a caller's std::source_location).


The documentation for this class was generated from the following file: