Blammo-wai-0.0.0.0: Using Blammo with WAI
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.Wai.Middleware.Logging

Synopsis

Documentation

addThreadContext :: [Pair] -> Middleware Source #

Add context to any logging done from the request-handling thread

requestLogger :: HasLogger env => env -> Middleware Source #

Log requests (more accurately, responses) as they happen

In JSON format, logged messages look like:

{
  ...
  message: {
    text: "GET foobar => 200 OK",
    meta: {
      method: GET,
      path: "foobar",
      query: "?baz=bat&quix=quo",
      status: {
        code: 200,
        message: OK
      },
      durationMs: 1322.2,
      requestHeaders: {
        Authorization: "***",
        Accept: "text/html",
        Cookie: "***"
      },
      responseHeaders: {
        Set-Cookie: "***",
        Expires: "never"
      }
    }
  }
}

Configuration

setConfigLogSource :: LogSource -> Config -> Config Source #

Change the source used for log messages

Default is requestLogger.

setConfigGetClientIp :: (Request -> Text) -> Config -> Config Source #

Change how the clientIp field is determined

Default is looking up the first value in x-forwarded-for, then the x-real-ip header, then finally falling back to remoteHost.

setConfigGetDestinationIp :: (Request -> Maybe Text) -> Config -> Config Source #

Change how the destinationIp field is determined

Default is looking up the x-real-ip header.

NOTE: Our default uses a somewhat loose definition of destination. It would be more accurate to report the resolved IP address of the Host header, but we don't have that available. Our default of x-real-ip favors containerized Warp on AWS/ECS, where this value holds the ECS target container's IP address. This is valuable debugging information and could, if you squint, be considered a destination.