Github   Telegram
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
logging::LogExtra Class Referencefinal

Extra tskv fields storage. More...

#include <userver/logging/log_extra.hpp>

Public Types

enum class  ExtendType {
  kNormal ,
  kFrozen
}
 Specifies replacement policy for newly added values. More...
 
using Value = std::variant< std::string, int, long, long long, unsigned int, unsigned long, unsigned long long, float, double >
 
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. More...
 
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 (const logging::LoggerPtr &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 (const logging::LoggerPtr &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.
 

Friends

class LogHelper
 
class tracing::Span
 

Detailed Description

Extra tskv fields storage.

Definition at line 28 of file log_extra.hpp.

Member Typedef Documentation

◆ Key

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

Definition at line 32 of file log_extra.hpp.

◆ Pair

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

Definition at line 33 of file log_extra.hpp.

◆ Value

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

Definition at line 30 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 36 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 98 of file log_extra.hpp.

Friends And Related Function Documentation

◆ LogHelper

friend class LogHelper
friend

Definition at line 108 of file log_extra.hpp.

◆ tracing::Span

friend class tracing::Span
friend

Definition at line 109 of file log_extra.hpp.


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