ButlerMDC#
- class lsst.daf.butler.logging.ButlerMDC#
Bases:
objectHandle setting and unsetting of global MDC records.
The Mapped Diagnostic Context (MDC) can be used to set context for log messages.
Currently there is one global MDC dict. Per-thread MDC is not yet supported.
Methods Summary
MDC(key, value)Set MDC for this key to the supplied value.
MDCRemove(key)Clear the MDC value associated with this key.
Add a log record factory that adds a MDC record to
LogRecord.Clear all MDC entries.
Restores the log record factory to the original form.
set_mdc(mdc)Set the MDC key for this context.
Methods Documentation
- classmethod MDC(key: str, value: str) str#
Set MDC for this key to the supplied value.
Parameters#
- key
str Key to modify.
- value
str New value to use.
Returns#
- old
str The previous value for this key.
- key
- classmethod MDCRemove(key: str) None#
Clear the MDC value associated with this key.
Can be called even if the key is not known to MDC.
Parameters#
- key
str Key for which the MDC value should be removed.
- key
- classmethod add_mdc_log_record_factory() None#
Add a log record factory that adds a MDC record to
LogRecord.
- classmethod clear_mdc() None#
Clear all MDC entries.
- classmethod restore_log_record_factory() None#
Restores the log record factory to the original form.
Does nothing if there has not been a call to
add_mdc_log_record_factory.
- classmethod set_mdc(mdc: dict[str, str]) Generator[None, None, None]#
Set the MDC key for this context.
This context manager also adds a mapping named
mdcto any exceptions that escape it.Parameters#
- mdc
dictofstr,str MDC keys to update temporarily.
Notes#
Other MDC keys are not modified. The previous values are restored on exit (removing them if the were unset previously).
- mdc