wai-extra-1.3.3.2: Provides some basic WAI handlers and middleware.

Safe Haskell | None

Network.Wai.Middleware.RequestLogger

Contents

- Basic stdout logging
- Create more versions

Synopsis

- logStdout :: Middleware
- logStdoutDev :: Middleware
- mkRequestLogger :: RequestLoggerSettings -> IO Middleware
- data RequestLoggerSettings
- outputFormat :: RequestLoggerSettings -> OutputFormat
- autoFlush :: RequestLoggerSettings -> Bool
- destination :: RequestLoggerSettings -> Destination
- data OutputFormat
  - = Apache IPAddrSource
  - | Detailed Bool
  - | CustomOutputFormat OutputFormatter
- type OutputFormatter = ZonedDate -> Request -> Status -> Maybe Integer -> [LogStr]
- data Destination
  - = Handle Handle
  - | Logger Logger
  - | Callback Callback
- type Callback = [LogStr] -> IO ()
- data IPAddrSource
  - = FromSocket
  - | FromHeader

# Basic stdout logging

logStdout :: Middleware Source

Production request logger middleware. Implemented on top of logCallback, but prints to `stdout`

logStdoutDev :: Middleware Source

Development request logger middleware. Implemented on top of logCallbackDev, but prints to `stdout`

Flushes `stdout` on each request, which would be inefficient in production use. Use logStdout in production.

# Create more versions

mkRequestLogger :: RequestLoggerSettings -> IO Middleware Source

data RequestLoggerSettings Source

Instances

Default RequestLoggerSettings |

outputFormat :: RequestLoggerSettings -> OutputFormat Source

Default value: `Detailed` `True`.

autoFlush :: RequestLoggerSettings -> Bool Source

Only applies when using the `Handle` constructor for `destination`.

Default value: `True`.

destination :: RequestLoggerSettings -> Destination Source

Default: `Handle` `stdout`.

data OutputFormat Source

Constructors

Apache IPAddrSource |
Detailed Bool | use colors?
CustomOutputFormat OutputFormatter |

type OutputFormatter = ZonedDate -> Request -> Status -> Maybe Integer -> [LogStr]Source

data Destination Source

Constructors

Handle Handle |
Logger Logger |
Callback Callback |

type Callback = [LogStr] -> IO ()Source

data IPAddrSource

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

Constructors

FromSocket | From the peer address of the HTTP connection.
FromHeader | From X-Real-IP: or X-Forwarded-For: in the HTTP header.