6 #ifndef SL_LOG_RECORD_BUILDER_HPP
7 #define SL_LOG_RECORD_BUILDER_HPP
15 #include <type_traits>
29 template <
class TSeverityLevel>
42 noexcept(std::is_nothrow_move_constructible_v<Sev_t>) :
43 m_Data{ std::move(data) }
52 template <Record TRecord>
55 rec.setSeverity(m_Data);
68 template <
class TChannel>
81 std::is_nothrow_move_constructible_v<Chan_t>) :
82 m_Data{ std::move(data) }
91 template <Record TRecord>
94 rec.setChannel(m_Data);
108 template <Record TRecord>
117 using LogCallback_t = std::function<void(
Record_t)>;
130 m_Record{ std::move(prefabRec) },
131 m_LogCallback{ std::move(cb) }
145 m_Record.setMessage(std::move(m_Stream).str());
146 m_LogCallback(std::move(m_Record));
161 *
this = std::move(other);
173 swap(m_Record, other.m_Record);
174 swap(m_Stream, other.m_Stream);
175 m_LogCallback = std::exchange(other.m_LogCallback, {});
216 { std::declval<std::ostringstream>() << std::forward<T>(data) };
220 m_Stream << std::forward<T>(data);
229 template <std::invocable<Record_t&> TAction>
232 std::invoke(action, m_Record);
238 std::ostringstream m_Stream;
239 LogCallback_t m_LogCallback;
Helper class for building new Records.
Definition: RecordBuilder.hpp:110
RecordBuilder(RecordBuilder &&other) noexcept
Move constructor.
Definition: RecordBuilder.hpp:159
const Record_t & record() const noexcept
Const accessor to the internal record object.
Definition: RecordBuilder.hpp:201
RecordChannel_t< Record_t > Channel_t
Definition: RecordBuilder.hpp:114
Record_t & record() noexcept
Accessor to the internal record object.
Definition: RecordBuilder.hpp:192
requires requires(T &&data)
Output operator.
Definition: RecordBuilder.hpp:214
~RecordBuilder() noexcept
Destructor.
Definition: RecordBuilder.hpp:139
RecordBuilder & operator=(RecordBuilder &&other) noexcept
Move-assign operator.
Definition: RecordBuilder.hpp:170
std::remove_cvref_t< TRecord > Record_t
Definition: RecordBuilder.hpp:112
RecordBuilder & operator<<(T &&data)
Definition: RecordBuilder.hpp:218
RecordSeverity_t< Record_t > SeverityLevel_t
Definition: RecordBuilder.hpp:113
RecordBuilder(const RecordBuilder &)=delete
Deleted copy constructor.
RecordBuilder(Record_t prefabRec, LogCallback_t cb) noexcept
Constructor.
Definition: RecordBuilder.hpp:129
Manipulates the channel of the current RecordBuilder object.
Definition: RecordBuilder.hpp:70
void operator()(TRecord &rec) const
Changes channel of the passed Record object.
Definition: RecordBuilder.hpp:92
TChannel Chan_t
Definition: RecordBuilder.hpp:72
constexpr SetChan(TChannel data) noexcept(std::is_nothrow_move_constructible_v< Chan_t >)
Constructor accepting channel data.
Definition: RecordBuilder.hpp:78
Manipulates the channel of the current RecordBuilder object.
Definition: RecordBuilder.hpp:31
constexpr SetSev(TSeverityLevel data) noexcept(std::is_nothrow_move_constructible_v< Sev_t >)
Constructor accepting severity level data.
Definition: RecordBuilder.hpp:39
TSeverityLevel Sev_t
Definition: RecordBuilder.hpp:33
void operator()(TRecord &rec) const
Changes severity level of the passed Record object.
Definition: RecordBuilder.hpp:53
typename RecordTypedefs< TRecord >::Severity_t RecordSeverity_t
Typedef for easier access to Record's severity type.
Definition: Record.hpp:69
typename RecordTypedefs< TRecord >::Channel_t RecordChannel_t
Typedef for easier access to Record's channel type.
Definition: Record.hpp:81
Definition: BasicSink.hpp:22