Copyright | (c) Isaac van Bakel 2020 |
---|---|
License | BSD3 |
Maintainer | ivb@vanbakel.io |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Katip's structured logging is useful, but adding logging after-the-fact to a Yesod site which already uses the Yesod-provided logging invocations can be a lot of work.
This module provides several convenience wrappers for converting existing Yesod sites into Katip-using versions without needing to modify any handlers. Instead, the wrapped versions will add in HTTP structures like requests, etc. automatically, and logs sent to Yesod will be intercepted and also sent to Katip along with any structure.
These wrappers are configurable - they can be made to redirect logs, duplicate
them (sending both to Katip and the Yesod logger), or even ignore them, as
necessary. See KatipConfig
for more detail.
If your site has a Yesod
instance, so will the wrapped version - so using it
is as simple as passing the wrapped version along to WAI, or whichever server
you use.
There's also support for using Katip's API for more direct control over your
Katip logs inside Yesod handlers. This is based in SiteKatip
, which is a
ytl-style site class.
Synopsis
- newtype KatipSite site = KatipSite {
- unKatipSite :: ReaderSite (KatipConfig, LogEnv) site
- data KatipContextSite site = KatipContextSite {
- unKatipContextSite :: ReaderSite (KatipConfig, LogEnv, LogContexts, Namespace) site
- data KatipConfig = KatipConfig {}
- data LoggingApproach
Documentation
newtype KatipSite site Source #
A wrapper for adding Katip functionality to a site.
This is the most basic wrapper. It will allow you to redirect logs from
Yesod to Katip, as configured. It will not include HTTP structures in the
output - for that, look at KatipContextSite
instead.
KatipSite | |
|
Instances
data KatipContextSite site Source #
A wrapper for adding Katip functionality to a site.
This is the more featureful wrapper. It can redirect logs, just like
KatipSite
, but will also augment them with useful HTTP structure from
Yesod.
KatipContextSite | |
|
Instances
data KatipConfig Source #
Configuration for how KatipSite
and KatipContextSite
turn Yesod logs
into Katip ones
KatipConfig | |
|
Instances
Default KatipConfig Source # | |
Defined in Yesod.Katip def :: KatipConfig # |
data LoggingApproach Source #
Control how the Katip wrapper directs logs that come from Yesod.
Regardless of the choice of approach, logs will only be sent when
shouldLogIO
says they should.
YesodOnly | Send these logs only to the Yesod logger configured by the site's Yesod instance already. This is provided only for debugging convenience - it doesn't make sense to use it in production. |
KatipOnly | Send these logs only to the Katip scribes, ignoring the Yesod logger. |
Both | Send logs to both the Katip scribes and the Yesod logger. If Katip is configured to log structure as well, this structure *won't* be sent to the Yesod logger. This is the default. |