API reference

safir Package

Safir is the SQuaRE framework for Roundtable bots.

Variables

__version__ The version string of Safir (PEP 440 / SemVer compatible).
version_info The decomposed version, split across “..”

safir.http Module

Utilities for using the aiohttp client in Safir-based apps.

Functions

init_http_session(app) Create an aiohttp.ClientSession and make it available as a "safir/http_session" key on the application.

safir.logging Module

Utilities for configuring structlog-based logging.

Functions

configure_logging(*, name, profile, log_level) Configure logging and structlog.
get_response_logger() Get the context-local structlog logger with bound request context.

Variables

response_logger A context-local structlog logger.

safir.metadata Module

Standardized metadata for Roundtable HTTP services.

Functions

setup_metadata(*, package_name, app, **kwargs) Add a metadata object to the application under the safir/metadata key.
get_project_url(meta, label) Get a specific URL from the project_urls key of a package’s metadata.

safir.middleware Module

Middleware for aiohttp.web servers.

Functions

bind_logger(request, handler) Bind request metadata to the context-local structlog logger.