wai-log-0.1.0.0: A logging middleware for WAI applications

Safe HaskellNone
LanguageHaskell2010

Network.Wai.Log

Description

A simple logging middleware for WAI applications that supports the 'log-*' family of packages: https://hackage.haskell.org/package/log-base

Currently there are no logging options but contributions are welcome. When logging to stdout, the output looks like this:

2019-02-21 19:51:47 INFO my-server: Request received {
  "url": "/api/myapi",
  "body-length": "KnownLength 0",
  "method": "GET",
  "user-agent": "curl/7.54.0",
  "remote-host": "127.0.0.1:61249"
}
2019-02-21 19:51:47 INFO my-server: Sending response
2019-02-21 19:51:47 INFO my-server: Request complete {
  "status": {
    "code": 200,
    "message": "OK"
  },
  "time": {
    "process": 2.224e-3,
    "full": 2.348e-3
  }
}
Synopsis

Documentation

logRequestsWith :: (LogT IO () -> IO ()) -> Middleware Source #

Given a logger, create a Middleware that logs incoming requests, the response code, and how long it took to process and respond to the request.