LogCapture

class lsst.pipe.base.log_capture.LogCapture(butler: LimitedButler, full_butler: Butler | None)

Bases: object

Class handling capture of logging messages and their export to butler.

Parameters:
butlerLimitedButler

Data butler with limited API.

full_butlerButler or None

Data butler with full API, or None if full Butler is not available. If not none, then this must be the same instance as butler.

Attributes Summary

stream_json_logs

If True each log record is written to a temporary file and ingested when quantum completes.

Methods Summary

capture_logging(task_node, /, quantum)

Configure logging system to capture logs for execution of this task.

from_full(butler)

from_limited(butler)

Attributes Documentation

stream_json_logs = True

If True each log record is written to a temporary file and ingested when quantum completes. If False the records are accumulated in memory and stored in butler on quantum completion. If full butler is not available then temporary file is not used.

Methods Documentation

capture_logging(task_node: TaskNode, /, quantum: Quantum) Iterator[_LogCaptureFlag]

Configure logging system to capture logs for execution of this task.

Parameters:
task_nodeTaskNode

The task definition.

quantumQuantum

Single Quantum instance.

Notes

Expected to be used as a context manager to ensure that logging records are inserted into the butler once the quantum has been executed:

with self.capture_logging(task_node, quantum):
    # Run quantum and capture logs.

Ths method can also setup logging to attach task- or quantum-specific information to log messages. Potentially this can take into account some info from task configuration as well.

classmethod from_full(butler: Butler) LogCapture
classmethod from_limited(butler: LimitedButler) LogCapture