6#include <initializer_list>
11#include <boost/container/container_fwd.hpp>
13#include <userver/compiler/select.hpp>
14#include <userver/logging/fwd.hpp>
15#include <userver/logging/json_string.hpp>
16#include <userver/utils/fast_pimpl.hpp>
18USERVER_NAMESPACE_BEGIN
39 using Value = std::variant<
50 using Key = std::string;
51 using Pair = std::pair<Key, Value>;
61 LogExtra(
const LogExtra&);
69 LogExtra& operator=(LogExtra&&);
71 LogExtra& operator=(
const LogExtra&);
112 template <
typename Iterator>
115 for (Iterator it = first; it != last; ++it) Extend(*it, extend_type);
122 friend class LogHelper;
123 friend class impl::TagWriter;
128 const Value& GetValue(std::string_view key)
const;
130 class ProtectedValue
final {
132 ProtectedValue() =
default;
133 ProtectedValue(Value value,
bool frozen);
134 ProtectedValue(
const ProtectedValue& other) =
default;
135 ProtectedValue(ProtectedValue&& other) =
default;
137 ProtectedValue& operator=(
const ProtectedValue& other);
138 ProtectedValue& operator=(ProtectedValue&& other)
noexcept;
140 bool IsFrozen()
const;
142 Value& GetValue() {
return value_; }
143 const Value& GetValue()
const {
return value_; }
144 void AssignIgnoringFrozenness(ProtectedValue other);
148 bool frozen_ =
false;
151 static constexpr std::size_t kSmallVectorSize = 24;
152 static constexpr std::size_t kPimplSize =
153 compiler::SelectSize().ForLibCpp32(1168).ForLibCpp64(1560).ForLibStdCpp64(1944).ForLibStdCpp32(1356);
154 using MapItem = std::pair<Key, ProtectedValue>;
155 using Map = boost::container::small_vector<MapItem, kSmallVectorSize>;
161 std::pair<Key, ProtectedValue>* Find(std::string_view);
163 const std::pair<Key, ProtectedValue>* Find(std::string_view)
const;
165 utils::FastPimpl<Map, kPimplSize,
alignof(
void*)> extra_;
168extern const LogExtra kEmptyLogExtra;