peyk.transport.logging_hook

Minimal transport logging hook.

Not a full logging system — peyk is a separate repo from hazardastan and has no access to its richer logger. This is deliberately just a three-method Protocol plus a stdlib-logging-backed default, so callers (including hazardastan’s eventual adapter) can supply their own implementation without peyk depending on anything beyond the stdlib.

Functions

get_default_logger()

A shared, lazily-created StdlibTransportLogger instance.

Classes

StdlibTransportLogger([logger])

Default TransportLogger, backed by logging.getLogger("peyk.transport").

TransportLogger(*args, **kwargs)

Logging hook used by the transport layer.

class peyk.transport.logging_hook.TransportLogger(*args, **kwargs)[source]

Bases: Protocol

Logging hook used by the transport layer.

The protocol separates request, event, retry, and final-failure logging.

log_request(method: str, url: str) None[source]

Performs the log request operation for the transport client.

Parameters:
  • method – Value used by this operation.

  • url – Target URL.

log_event(event: object) None[source]

Performs the log event operation for the transport client.

Parameters:

event – Value used by this operation.

log_retry(attempt: int, exception: Exception) None[source]

Performs the log retry operation for the transport client.

Parameters:
  • attempt – Value used by this operation.

  • exception – Value used by this operation.

log_failure(exception: Exception) None[source]

Performs the log failure operation for the transport client.

Parameters:

exception – Value used by this operation.

class peyk.transport.logging_hook.StdlibTransportLogger(logger: Logger | None = None)[source]

Bases: object

Default TransportLogger, backed by logging.getLogger(“peyk.transport”).

Requests log at DEBUG (high-volume, opt-in visibility), retries at WARNING (worth noticing but expected/handled), failures at ERROR (nothing left to retry — the caller now has to deal with it).

log_request(method: str, url: str) None[source]

Performs the log request operation for the transport client.

Parameters:
  • method – Value used by this operation.

  • url – Target URL.

log_event(event: object) None[source]

Performs the log event operation for the transport client.

Parameters:

event – Value used by this operation.

log_retry(attempt: int, exception: Exception) None[source]

Performs the log retry operation for the transport client.

Parameters:
  • attempt – Value used by this operation.

  • exception – Value used by this operation.

log_failure(exception: Exception) None[source]

Performs the log failure operation for the transport client.

Parameters:

exception – Value used by this operation.

peyk.transport.logging_hook.get_default_logger() TransportLogger[source]

A shared, lazily-created StdlibTransportLogger instance.

Used by Session and run_with_retry when no TransportLogger is passed explicitly, so A1’s existing call sites (which never pass a logger) keep working unmodified.

Returns:

The operation result (TransportLogger).