ButlerMDC¶
- class lsst.daf.butler.logging.ButlerMDC¶
Bases:
object
Handle 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 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 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
mdc
to any exceptions that escape it.Notes
Other MDC keys are not modified. The previous values are restored on exit (removing them if the were unset previously).