Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+7fec47d7bc,g07dc498a13+5ab4d22ec3,g0fba68d861+565de8e5d5,g1409bbee79+5ab4d22ec3,g1a7e361dbc+5ab4d22ec3,g1fd858c14a+11200c7927,g20f46db602+25d63fd678,g35bb328faa+fcb1d3bbc8,g4d2262a081+61302e889d,g4d39ba7253+d05e267ece,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+d05e267ece,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8048e755c2+a1301e4c20,g8852436030+163ceb82d8,g89139ef638+5ab4d22ec3,g89e1512fd8+fbb808ebce,g8d6b6b353c+d05e267ece,g9125e01d80+fcb1d3bbc8,g989de1cb63+5ab4d22ec3,g9f33ca652e+8abe617c77,ga9baa6287d+d05e267ece,gaaedd4e678+5ab4d22ec3,gabe3b4be73+1e0a283bba,gb1101e3267+fefe9ce5b1,gb58c049af0+f03b321e39,gb90eeb9370+824c420ec4,gc741bbaa4f+77ddc33078,gcf25f946ba+163ceb82d8,gd315a588df+0f88d5218e,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+e6bd566e97,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,w.2025.10
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
lsst::log::LogMDCScope Class Reference

#include <Log.h>

Public Member Functions

 LogMDCScope (std::string const &key, std::string const &value)
 Constructor adds KEY/VALUE pair to current thread MDC.
 
 LogMDCScope (LogMDCScope const &)=delete
 
LogMDCScopeoperator= (LogMDCScope const &)=delete
 
 LogMDCScope (LogMDCScope &&other)
 
LogMDCScopeoperator= (LogMDCScope &&other)
 
 ~LogMDCScope ()
 Destructor restores old key value in MDC.
 

Detailed Description

Definition at line 807 of file Log.h.

Constructor & Destructor Documentation

◆ LogMDCScope() [1/3]

lsst::log::LogMDCScope::LogMDCScope ( std::string const & key,
std::string const & value )
inline

Constructor adds KEY/VALUE pair to current thread MDC.

Key should not be empty (not checked).

Definition at line 814 of file Log.h.

815 : _key(key)
816 {
817 _oldValue = Log::MDC(key, value);
818 }
static std::string MDC(std::string const &key, std::string const &value)
Places a KEY/VALUE pair in the Mapped Diagnostic Context (MDC) for the current thread.
Definition Log.cc:274

◆ LogMDCScope() [2/3]

lsst::log::LogMDCScope::LogMDCScope ( LogMDCScope const & )
delete

◆ LogMDCScope() [3/3]

lsst::log::LogMDCScope::LogMDCScope ( LogMDCScope && other)
inline

Definition at line 824 of file Log.h.

824 {
825 _key = other._key;
826 _oldValue = other._oldValue;
827 other._key.clear();
828 }

◆ ~LogMDCScope()

lsst::log::LogMDCScope::~LogMDCScope ( )
inline

Destructor restores old key value in MDC.

Definition at line 847 of file Log.h.

847 {
848 if (not _key.empty()) {
849 if (_oldValue.empty()) {
850 Log::MDCRemove(_key);
851 } else {
852 Log::MDC(_key, _oldValue);
853 }
854 }
855 }
static void MDCRemove(std::string const &key)
Remove the value associated with KEY within the MDC.
Definition Log.cc:288

Member Function Documentation

◆ operator=() [1/2]

LogMDCScope & lsst::log::LogMDCScope::operator= ( LogMDCScope && other)
inline

Definition at line 830 of file Log.h.

830 {
831 if (not _key.empty()) {
832 if (_oldValue.empty()) {
833 Log::MDCRemove(_key);
834 } else {
835 Log::MDC(_key, _oldValue);
836 }
837 }
838 _key = other._key;
839 _oldValue = other._oldValue;
840 other._key.clear();
841 return *this;
842 }

◆ operator=() [2/2]

LogMDCScope & lsst::log::LogMDCScope::operator= ( LogMDCScope const & )
delete

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