katip-wai-0.1.1.0: WAI middleware for logging request and response info through katip.
Safe HaskellNone
LanguageHaskell2010

Katip.Wai

Description

Add information about Request, response, and the elapsed time to Katip's LogContexts.

The following is added to the context as "response":

  • "elapsedTimeInNanoSeconds": Amount of time from receiving the request to sending the response in nano seconds.
  • "status": The status of the response, ie. 200, 202, 204, 400, 404, 500, etc.
Synopsis

Middleware

defaultFormat :: UUID -> Request -> Value Source #

Default format for the request. The requestId will be unique every time we call this function, it's an id to correlate logs generated by the request.

Current format:

  • "id": Uniquely generated string that can be used to correlate logs to a single request.
  • "httpVersion": Version of the request.
  • "remoteHost": Address the request came from.
  • "isSecure": True if the request was made over an SSL connection, otherwise false.
  • "method": HTTP Method used for the request, ie. GET, POST, PUT, PATCH, DELETE, etc.
  • "path": URL without a hostname, port, or querystring.
  • "queryString": Query string of the request if one was sent.
  • "bodyLength": Size of the body in the request.
  • "headers.host": Value of the "Host" header.
  • "headers.referer": Value of the "Referer" header.
  • "headers.userAgent": Value of the "User-Agent" header.
  • "headers.range": Value of the "Range" header.

middlewareWithFormatter :: KatipContext m => (UUID -> Request -> Value) -> Severity -> MiddlewareT m Source #

Logs the request using the provided format, response, and elapsed time in Katip's context

middleware :: KatipContext m => Severity -> MiddlewareT m Source #

Logs the request, response, and elapsed time in Katip's context

Helpers for threading Katip's Context throughout the entire Application

type ApplicationT m = Request -> (Response -> m ResponseReceived) -> m ResponseReceived Source #

Just like Application except it runs in m instead of IO

type MiddlewareT m = ApplicationT m -> ApplicationT m Source #

Just like Middleware except it runs in m instead of IO

runApplication :: MonadIO m => (forall a. m a -> IO a) -> ApplicationT m -> Application Source #

Converts an ApplicationT to a normal Application