wai-extra-3.1.10: Provides some basic WAI handlers and middleware.
Safe HaskellNone



Basic stdout logging

logStdout :: Middleware Source #

Production request logger middleware.

This uses the Apache logging format, and takes IP addresses for clients from the socket (see IPAddrSource for more information). It logs to stdout.

logStdoutDev :: Middleware Source #

Development request logger middleware.

This uses the Detailed True logging format and logs to stdout.

Create more versions

data RequestLoggerSettings Source #

RequestLoggerSettings is an instance of Default. See Data.Default for more information.

outputFormat, autoFlush, and destination are record fields for the record type RequestLoggerSettings, so they can be used to modify settings values using record syntax.


Instances details
Default RequestLoggerSettings Source # 
Instance details

Defined in Network.Wai.Middleware.RequestLogger

outputFormat :: RequestLoggerSettings -> OutputFormat Source #

Default value: Detailed True.

autoFlush :: RequestLoggerSettings -> Bool Source #

Only applies when using the Handle constructor for destination.

Default value: True.

data ApacheSettings Source #

Settings for the ApacheWithSettings OutputFormat. This is purposely kept as an abstract data type so that new settings can be added without breaking backwards compatibility. In order to create an ApacheSettings value, use defaultApacheSettings and the various 'setApache' functions to modify individual fields. For example:

setApacheIPAddrSource FromHeader defaultApacheSettings

Since: 3.1.8

setApacheIPAddrSource :: IPAddrSource -> ApacheSettings -> ApacheSettings Source #

Where to take IP addresses for clients from. See IPAddrSource for more information.

Default value: FromSocket

Since: 3.1.8

setApacheRequestFilter :: (Request -> Response -> Bool) -> ApacheSettings -> ApacheSettings Source #

Function that allows you to filter which requests are logged, based on the request and response

Default: log all requests

Since: 3.1.8

setApacheUserGetter :: (Request -> Maybe ByteString) -> ApacheSettings -> ApacheSettings Source #

Function that allows you to get the current user from the request, which will then be added in the log.

Default: return no user

Since: 3.1.8

data DetailedSettings Source #

Settings for the Detailed OutputFormat.

mModifyParams allows you to pass a function to hide confidential information (such as passwords) from the logs. If result is Nothing, then the parameter is hidden. For example: > myformat = Detailed True (Just hidePasswords) > where hidePasswords p@(k,v) = if k = "password" then (k, "***REDACTED***") else p

mFilterRequests allows you to filter which requests are logged, based on the request and response.

Since: 3.1.3


Instances details
Default DetailedSettings Source # 
Instance details

Defined in Network.Wai.Middleware.RequestLogger

type OutputFormatterWithDetailsAndHeaders Source #


 = ZonedDate

When the log message was generated

-> Request

The WAI request

-> Status

HTTP status code

-> Maybe Integer

Response size

-> NominalDiffTime

Duration of the request

-> [ByteString]

The request body

-> Builder

Raw response

-> [Header]

The response headers

-> LogStr 

Same as OutputFormatterWithDetails but with response headers included

This is useful if you wish to include arbitrary application data in your logs, e.g., an authenticated user ID, which you would set in a response header in your application and retrieve in the log formatter.

Since: 3.0.27

type Callback = LogStr -> IO () Source #

data IPAddrSource #

Source from which the IP source address of the client is obtained.



From the peer address of the HTTP connection.


From X-Real-IP: or X-Forwarded-For: in the HTTP header.


From the peer address if header is not found.