userver: logging::LogExtra Class Reference
Loading...
Searching...
No Matches
logging::LogExtra Class Referencefinal

#include <userver/logging/log_extra.hpp>

Detailed Description

Extra tskv fields storage.

Definition at line 36 of file log_extra.hpp.

Public Types

enum class  ExtendType {
  kNormal ,
  kFrozen
}
 Specifies replacement policy for newly added values. More...
 
using Value
 
using Key = std::string
 
using Pair = std::pair<Key, Value>
 

Public Member Functions

 LogExtra (const LogExtra &)
 
 LogExtra (LogExtra &&)
 
LogExtraoperator= (LogExtra &&)
 
LogExtraoperator= (const LogExtra &)
 
 LogExtra (std::initializer_list< Pair > initial, ExtendType extend_type=ExtendType::kNormal)
 Constructs LogExtra containing an initial batch of key-value pairs.
 
void Extend (std::string key, Value value, ExtendType extend_type=ExtendType::kNormal)
 Adds a single key-value pair.
 
void Extend (Pair extra, ExtendType extend_type=ExtendType::kNormal)
 Adds a single key-value pair.
 
void Extend (std::initializer_list< Pair > extra, ExtendType extend_type=ExtendType::kNormal)
 Adds a batch of key-value pairs.
 
void Extend (const LogExtra &extra)
 Merges contents of other LogExtra with existing key-value pairs preserving freeze states.
 
void Extend (LogExtra &&extra)
 Merges contents of other LogExtra with existing key-value pairs preserving freeze states.
 
template<typename Iterator >
void ExtendRange (Iterator first, Iterator last, ExtendType extend_type=ExtendType::kNormal)
 Adds a range of key-value pairs.
 
void SetFrozen (const std::string &key)
 Marks specified value as frozen, all attempts to overwrite it will be silently ignored.
 

Static Public Member Functions

static LogExtra StacktraceNocache () noexcept
 Creates a LogExtra with current thread's stacktrace if the default log level is less or equal to DEBUG.
 
static LogExtra StacktraceNocache (logging::LoggerRef logger) noexcept
 Creates a LogExtra with current thread's stacktrace if the logger log level is less or equal to DEBUG.
 
static LogExtra Stacktrace () noexcept
 Creates a LogExtra with current thread's stacktrace if the logger log level is less or equal to DEBUG. Uses cache for faster stacktrace symbolization.
 
static LogExtra Stacktrace (logging::LoggerRef logger) noexcept
 Creates a LogExtra with current thread's stacktrace if the logger log level is less or equal to DEBUG. Uses cache for faster stacktrace symbolization.
 

Member Typedef Documentation

◆ Key

using logging::LogExtra::Key = std::string

Definition at line 40 of file log_extra.hpp.

◆ Pair

using logging::LogExtra::Pair = std::pair<Key, Value>

Definition at line 41 of file log_extra.hpp.

◆ Value

using logging::LogExtra::Value
Initial value:
std::variant<std::string, int, long, long long, unsigned int, unsigned long, unsigned long long, float, double>

Definition at line 38 of file log_extra.hpp.

Member Enumeration Documentation

◆ ExtendType

enum class logging::LogExtra::ExtendType
strong

Specifies replacement policy for newly added values.

Enumerator
kNormal 

Added value can be replaced.

kFrozen 

Attempts to replace this value will be ignored.

Definition at line 44 of file log_extra.hpp.

Member Function Documentation

◆ ExtendRange()

template<typename Iterator >
void logging::LogExtra::ExtendRange ( Iterator first,
Iterator last,
ExtendType extend_type = ExtendType::kNormal )
inline

Adds a range of key-value pairs.

Definition at line 103 of file log_extra.hpp.

Friends And Related Symbol Documentation

◆ tracing::Span

friend class tracing::Span
friend

Definition at line 113 of file log_extra.hpp.

◆ tracing::TagScope

friend class tracing::TagScope
friend

Definition at line 114 of file log_extra.hpp.


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