52 using Value = std::variant<
64 using Key = std::string;
65 using Pair = std::pair<Key, Value>;
67 using ValueView = std::variant<
78 impl::JsonStringViewForInitializerList>;
80 using InitializerList = std::initializer_list<std::pair<std::string_view, ValueView>>;
83 enum class ExtendType {
90 LogExtra(
const LogExtra&);
98 LogExtra& operator=(LogExtra&&);
100 LogExtra& operator=(
const LogExtra&);
103 LogExtra(InitializerList initial, ExtendType extend_type = ExtendType::kNormal);
106 void Extend(std::string key, Value value, ExtendType extend_type = ExtendType::kNormal);
109 void Extend(Pair extra, ExtendType extend_type = ExtendType::kNormal);
112 void Extend(InitializerList extra, ExtendType extend_type = ExtendType::kNormal);
116 void Extend(
const LogExtra& extra);
120 void Extend(LogExtra&& extra);
124 static LogExtra StacktraceNocache()
noexcept;
128 static LogExtra StacktraceNocache(
logging::LoggerRef logger)
noexcept;
133 static LogExtra Stacktrace()
noexcept;
138 static LogExtra Stacktrace(
logging::LoggerRef logger)
noexcept;
141 template <
typename Iterator>
142 void ExtendRange(Iterator first, Iterator last, ExtendType extend_type = ExtendType::kNormal) {
144 for (Iterator it = first; it != last; ++it) {
145 Extend(*it, extend_type);
150 void SetFrozen(std::string_view key);
152 friend class LogHelper;
153 friend class impl::LogExtraTskvFormatter;
154 friend class impl::TagWriter;
159 const Value& GetValue(std::string_view key)
const;
161 class ProtectedValue
final {
163 ProtectedValue() =
default;
164 ProtectedValue(Value value,
bool frozen);
165 ProtectedValue(
const ProtectedValue& other) =
default;
166 ProtectedValue(ProtectedValue&& other) =
default;
168 ProtectedValue& operator=(
const ProtectedValue& other);
169 ProtectedValue& operator=(ProtectedValue&& other)
noexcept;
171 bool IsFrozen()
const noexcept;
172 void SetFrozen()
noexcept;
173 Value& GetValue()
noexcept {
return value_; }
174 const Value& GetValue()
const noexcept {
return value_; }
175 void AssignIgnoringFrozenness(ProtectedValue other);
179 bool frozen_ =
false;
182 static constexpr std::size_t kSmallVectorSize = 24;
183 static constexpr std::size_t kPimplSize =
184 compiler::
SelectSize().ForLibCpp32(1168).ForLibCpp64(1560).ForLibStdCpp64(1944).ForLibStdCpp32(1356);
185 using MapItem = std::pair<Key, ProtectedValue>;
186 using Map = boost::container::small_vector<MapItem, kSmallVectorSize>;
188 void Extend(std::string key, ProtectedValue protected_value, ExtendType extend_type = ExtendType::kNormal);
190 void Extend(MapItem extra, ExtendType extend_type = ExtendType::kNormal);
192 std::pair<Key, ProtectedValue>* Find(std::string_view);
194 const std::pair<Key, ProtectedValue>* Find(std::string_view)
const;
196 utils::FastPimpl<Map, kPimplSize,
alignof(
void*)> extra_;