Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- addThreadContext :: [Pair] -> Middleware
- addThreadContextFromRequest :: (Request -> [Pair]) -> Middleware
- requestLogger :: HasLogger env => env -> Middleware
- requestLoggerWith :: HasLogger env => Config -> env -> Middleware
- data Config
- defaultConfig :: Config
- setConfigLogSource :: LogSource -> Config -> Config
- setConfigGetClientIp :: (Request -> Text) -> Config -> Config
- setConfigGetDestinationIp :: (Request -> Maybe Text) -> Config -> Config
Documentation
addThreadContext :: [Pair] -> Middleware Source #
Add context to any logging done from the request-handling thread
addThreadContextFromRequest :: (Request -> [Pair]) -> Middleware Source #
addThreadContext
, but have the Request
available
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" } } } }
requestLoggerWith :: HasLogger env => Config -> env -> Middleware Source #
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.