gouge.preformatters

Pre-formatters: functions which rewrite the message of a record before Simple formats it.

A pre-formatter takes the message text and returns the new text. Map logger names to pre-formatters with the pre_formatters option of Simple.

gouge.preformatters.uvicorn_access(message)

Colour the access log lines of the uvicorn.access logger.

The client address is blue, the method green, yellow or red, the path bright white, the HTTP version cyan, and the status code coloured by its class (2xx green, 3xx yellow, 4xx blue, 5xx yellow on red). A message in any other form is returned unchanged.

Parameters:
message

The message of the record, with its arguments merged.

Return type:

str

Returns:

The message with ANSI colour codes added.