23#include "../../microfmt.hpp"
37 static_assert(TagCapacity > 0,
"Tag capacity must be at least 1 byte");
44 void set_tag(microfmt::string_view tag)
noexcept {
45 RELOCO_BEGIN_UNSAFE_BUFFER_USAGE;
47 tag_size_ = tag.size() < TagCapacity - 1 ? tag.size() : TagCapacity - 1;
48 for (std::size_t i = 0; i <
tag_size_; ++i) {
53 RELOCO_END_UNSAFE_BUFFER_USAGE;
65 [[nodiscard]] microfmt::string_view
resolve_tag(microfmt::string_view logger_name,
66 char (&scratch)[TagCapacity])
const &
noexcept RELOCO_LIFETIMEBOUND {
67 if (logger_name.empty()) {
71 RELOCO_BEGIN_UNSAFE_BUFFER_USAGE;
77 while (n < TagCapacity - 1 && n < logger_name.size()) {
78 scratch[n] = logger_name[n];
83 RELOCO_END_UNSAFE_BUFFER_USAGE;
84 return microfmt::string_view(scratch, n);
87 [[nodiscard]] microfmt::string_view
resolve_tag(microfmt::string_view logger_name,
88 char (&scratch)[TagCapacity])
const && =
delete;
CRTP-free base providing fixed-capacity tag storage and truncating tag resolution,...
Definition tagged_log_sink_base.hpp:36
constexpr tagged_log_sink_base() noexcept=default
char tag_[TagCapacity]
Definition tagged_log_sink_base.hpp:90
microfmt::string_view resolve_tag(microfmt::string_view logger_name, char(&scratch)[TagCapacity]) const &noexcept RELOCO_LIFETIMEBOUND
Resolves the tag to use for a record whose originating logger is named logger_name: that name (trunca...
Definition tagged_log_sink_base.hpp:65
std::size_t tag_size_
Definition tagged_log_sink_base.hpp:91
void set_tag(microfmt::string_view tag) noexcept
Replaces the default tag used for records whose logger has no name, truncating to fit if necessary.
Definition tagged_log_sink_base.hpp:44
microfmt::string_view resolve_tag(microfmt::string_view logger_name, char(&scratch)[TagCapacity]) const &&=delete
Fixed-capacity logger that formats records before dispatching to sinks.
Definition default_log_sink.template.hpp:125