slimta.logging.http

Utilities to make logging consistent and easy for WSGI-style requests and responses as well as more general HTTP logs.

class slimta.logging.http.HttpLogger(log)

Bases: object

Provides a limited set of log methods that slimta packages may use. This prevents free-form logs from mixing in with standard, machine- parseable logs.

Parameters:loglogging.Logger object to log through.
wsgi_request(environ)

Logs a WSGI-style request. This method pulls the appropriate info from environ and passes it to request().

Parameters:environ – The environment data.
wsgi_response(environ, status, headers)

Logs a WSGI-style response. This method passes its given info along to response().

Parameters:
  • environ – The environment data.
  • status – The status line given to the client, e.g. 404 Not Found.
  • headers – The headers returned in the response.
request(conn, method, path, headers[, is_client=True])

Logs an HTTP request.

Parameters:
  • conn (object) – The same object should be passed in this parameter to both this method and to its corresponding response(). There are no constraints on its type or value.
  • method – The request method string.
  • path – The path string.
  • headers – A list of (name, value) header tuples given in the request.
  • is_client (bool) – Whether or not the log line should be identified as a client- or server-side request.
response(conn, status, headers[, is_client=True])

Logs an HTTP response.

Parameters:
  • conn (object) – The same object should be passed in this parameter to both this method and to its corresponding request(). There are no constraints on its type or value.
  • status – The status string of the response, e.g. 200 OK.
  • headers – A list of (name, value) header tuples given in the response.
  • is_client (bool) – Whether or not the log line should be identified as a client- or server-side request.