Skip to content

Processors

processors #

CallPrettifier #

CallPrettifier(concise: bool = True)

A processor to format call information in the event dictionary.

Args: concise (bool): Whether to use a concise format for call information. Defaults to True.

Source code in src/imgtools/loggers/processors.py
def __init__(self, concise: bool = True) -> None:
    self.concise = concise

ESTTimeStamper #

ESTTimeStamper(fmt: str = '%Y-%m-%dT%H:%M:%S%z')

A processor to add a timestamp in Eastern Standard Time to the event dictionary.

Example

est_stamper = ESTTimeStamper() event_dict = {} est_stamper(None, None, event_dict)

format for just time:

est_stamper = ESTTimeStamper(fmt="%H:%M:%S")

Source code in src/imgtools/loggers/processors.py
def __init__(self, fmt: str = "%Y-%m-%dT%H:%M:%S%z") -> None:
    self.fmt = fmt
    self.est = pytz.timezone("US/Eastern")
    self._last_timestamp: str | None = None

JSONFormatter #

A processor to format the event dictionary for JSON output.

PathPrettifier #

PathPrettifier(
    base_dir: typing.Optional[pathlib.Path] = None,
)

A processor to convert absolute paths to relative paths based on a base directory.

Args: base_dir (Optional[Path]): The base directory to which paths should be made relative. Defaults to the current working directory.

Source code in src/imgtools/loggers/processors.py
def __init__(self, base_dir: Optional[Path] = None) -> None:
    self.base_dir = base_dir or Path.cwd()