Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Formatter a = a -> Value
- data TimeUnit
- type IncludedHeaders = Set HeaderName
- defaultIncludedHeaders :: IncludedHeaders
- defaultRequestFormat :: IncludedHeaders -> Formatter Request
- defaultResponseFormat :: IncludedHeaders -> TimeUnit -> Formatter Response
- data Options (m :: Type -> Type) = Options {
- handleRequest :: forall a. Request -> m a -> m a
- handleResponse :: forall a. Response -> m a -> m a
- addRequestAndResponseToContext :: forall (m :: Type -> Type). KatipContext m => Formatter Request -> Formatter Response -> Options m
- logRequestAndResponse :: forall (m :: Type -> Type). KatipContext m => Severity -> Options m
- options :: forall (m :: Type -> Type). KatipContext m => Formatter Request -> Formatter Response -> Severity -> Options m
- defaultOptions :: forall (m :: Type -> Type). KatipContext m => Severity -> Options m
Formatting
Unit of time to use when logging response times.
Instances
Bounded TimeUnit Source # | |
Enum TimeUnit Source # | |
Show TimeUnit Source # | |
Eq TimeUnit Source # | |
Ord TimeUnit Source # | |
Defined in Katip.Wai.Options |
type IncludedHeaders = Set HeaderName Source #
Headers to include in your logs.
defaultIncludedHeaders :: IncludedHeaders Source #
Default list of headers to include in logs: Host
, Referer
, 'User-Agent', and Range
.
defaultRequestFormat :: IncludedHeaders -> Formatter Request Source #
Default formatter for Request
s.
Example:
{ "headers": { Host: "localhost:4000", Referer: "http://localhost:4000/docs/", "User-Agent": "Mozilla5.0 (X11; Linux x86_64; rv:130.0) Gecko20100101 Firefox/130.0" }, "httpVersion": "HTTP/1.1", "id": "299b188e-f695-49ee-a92f-9078a29f2ec4", "isSecure": false, "method": GET, "path": "/openapi.json", "queryString": [], "receivedAt": "2024-09-07T18:22:50.943042066Z", "remoteHost": "127.0.0.1:58046" }
Options
data Options (m :: Type -> Type) Source #
Options to customize how to handle the Request
and Response
.
You can use Monoid
to combine Options
:
mconcat [ addRequestAndResponseToContext requestFormatter responseFormatter , logRequestAndResponse severity ]
Options | |
|
addRequestAndResponseToContext :: forall (m :: Type -> Type). KatipContext m => Formatter Request -> Formatter Response -> Options m Source #
Add the Request
to the LogContexts
under "request"
, and add Response
to the LogContext
under "response"
.
logRequestAndResponse :: forall (m :: Type -> Type). KatipContext m => Severity -> Options m Source #
Log "Request received."
when a request comes in, and log "Response sent."
when a response is sent back.
options :: forall (m :: Type -> Type). KatipContext m => Formatter Request -> Formatter Response -> Severity -> Options m Source #
Combines addRequestAndResponseToContext
and logRequestAndResponse
with the formatters and severity you provide.
defaultOptions :: forall (m :: Type -> Type). KatipContext m => Severity -> Options m Source #
Same as options
, but uses defaultRequestFormat
,defaultResponseFormat
, and Milliseconds
.