Skip to content

logger ¤

Logging utilities.

Functions:

  • double_brackets

    Double { and } in log messages to prevent formatting errors.

  • log_captured

    Log captured text.

  • redirect_output_to_logging

    Redirect standard output and error to logging.

  • run

    Run a subprocess, log its standard output and error, return its output.

  • tail

    Tail a log file.

double_brackets ¤

double_brackets(message: str) -> str

Double { and } in log messages to prevent formatting errors.

Parameters:

  • message (str) –

    The message to transform.

Returns:

  • str

    The updated message.

log_captured ¤

log_captured(
    text: str, level: str = "info", pkg: str | None = None
) -> None

Log captured text.

Parameters:

  • text (str) –

    The text to split and log.

  • level (str, default: 'info' ) –

    The log level to use.

redirect_output_to_logging ¤

redirect_output_to_logging(
    stdout_level: str = "info", stderr_level: str = "error"
) -> Iterator[None]

Redirect standard output and error to logging.

Yields:

run ¤

run(*args: str | Path, **kwargs: Any) -> str

Run a subprocess, log its standard output and error, return its output.

Parameters:

  • *args (str | Path, default: () ) –

    Command line arguments.

  • **kwargs (Any, default: {} ) –

    Additional arguments passed to subprocess.Popen.

Returns:

  • str

    The process standard output.

tail ¤

tail(log_file: str) -> None

Tail a log file.

Parameters:

  • log_file (str) –

    The log file to tail.