Skip to content

Logging API

RedactingFilter is what configure_logging() actually installs (see Secrets).

Logging configuration for the OMOP stack.

LoggingConfig

Bases: SecretSafeBaseModel

Logging overrides from the [logging] section of config.toml.

level overrides the verbosity-derived level for all OMOP loggers. loggers applies fine-grained level overrides to specific named loggers (e.g. {"sqlalchemy.engine": "INFO"}).

RedactingFilter

Bases: Filter

Scrubs credential-bearing URLs before a handler emits its record.

A filter rather than a formatter, for two reasons.

It reaches handlers that do their own rendering. e.g. RichHandler - a formatter attached to it governs only part of the result; Handler filters run in Handler.handle() before emit(), so concole and stream paths are covered by one mechanism and neither needs its own code path.

It survives customisation. Replacing a handler's formatter is an ordinary thing to do and must not silently remove a security guarantee. Redaction is not a presentation concern, so it does not live in the presentation layer.

configure_logging

configure_logging(
    config: LoggingConfig | _HasLoggingConfig | None = None,
    *,
    verbosity: int = 0,
    extra_namespaces: list[str] | None = None,
    console: Any = None,
) -> None

Configure Python logging for the OMOP stack.

Safe to call multiple times; re-applying the same arguments is idempotent.

Parameters:

Name Type Description Default
config LoggingConfig | _HasLoggingConfig | None

A LoggingConfig or a StackConfig (logging block extracted automatically). When config.level is set it takes precedence over verbosity.

None
verbosity int

Number of -v flags passed by the user. 0 → WARNING, 1 → INFO, 2+ → DEBUG.

0
extra_namespaces list[str] | None

Additional logger namespaces to configure alongside oa_configurator. Pass your package name here, e.g. extra_namespaces=["omop_graph"].

None

get_logger

get_logger(name: str) -> logging.Logger

Return a named logger; single import point for consuming packages.