ButlerLogRecord

class lsst.daf.butler.logging.ButlerLogRecord(*, name: str, asctime: datetime, message: str, levelno: int, levelname: str, filename: str, pathname: str, lineno: int, funcName: str | None = None, process: int, processName: str, exc_info: str | None = None, MDC: dict[str, str])

Bases: BaseModel

A model representing a logging.LogRecord.

A LogRecord always uses the current time in its record when recreated and that makes it impossible to use it as a serialization format. Instead have a local representation of a LogRecord that matches Butler needs.

Attributes Summary

model_computed_fields

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

Methods Summary

format([log_format])

Format this record.

from_record(record)

Create a new instance from a LogRecord.

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

Attributes Documentation

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'MDC': FieldInfo(annotation=dict[str, str], required=True), 'asctime': FieldInfo(annotation=datetime, required=True), 'exc_info': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'filename': FieldInfo(annotation=str, required=True), 'funcName': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'levelname': FieldInfo(annotation=str, required=True), 'levelno': FieldInfo(annotation=int, required=True), 'lineno': FieldInfo(annotation=int, required=True), 'message': FieldInfo(annotation=str, required=True), 'name': FieldInfo(annotation=str, required=True), 'pathname': FieldInfo(annotation=str, required=True), 'process': FieldInfo(annotation=int, required=True), 'processName': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

Methods Documentation

format(log_format: str | None = None) str

Format this record.

Parameters:
log_formatstr, optional

The format string to use. This string follows the standard f-style use for formatting log messages. If None the class default will be used.

Returns:
textstr

The formatted log message.

classmethod from_record(record: LogRecord) ButlerLogRecord

Create a new instance from a LogRecord.

Parameters:
recordlogging.LogRecord

The record from which to extract the relevant information.

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.