| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Snap.ErrorCollector
Description
snap-error-collector extends a Snap application with the ability to monitor
requests for uncaught exceptions. All routes are wrapped with an exception
handler, and exceptions are queued (and optionally filtered). Periodically,
the exception queue is flushed via an IO computation - you can use this
to send emails, notify yourself on Twitter, increment counters, etc.
Example:
import Snap.ErrorCollector initApp ::InitializerMyApp MyApp initApp = do ...collectErrorsErrorCollectorConfig{ecFlush= emailOpsTeam ,ecFlushInterval= 60000000 ,ecFilter=constTrue,ecUpperBound= 1000 } emailOpsTeam ::UTCTime->SeqLoggedException->Int->IO'()' emailOpsTeam = ...
- collectErrors :: ErrorCollectorConfig -> Initializer b v ()
- data LoggedException = LoggedException {
- leException :: !SomeException
- leLoggedAt :: !UTCTime
- leRequest :: !Request
- data ErrorCollectorConfig = ErrorCollectorConfig {
- ecFlush :: !(UTCTime -> Seq LoggedException -> Int -> IO ())
- ecFlushInterval :: !Int
- ecFilter :: !(SomeException -> Bool)
- ecExceptionUpperBound :: !Int
- basicConfig :: (UTCTime -> Seq LoggedException -> Int -> IO ()) -> ErrorCollectorConfig
Documentation
collectErrors :: ErrorCollectorConfig -> Initializer b v () Source #
Wrap a Snap website to collect errors.
data LoggedException Source #
An exception logged by snap-error-collector, tagged with the request that
caused the exception, and the time the exception occured.
Constructors
| LoggedException | |
Fields
| |
Instances
data ErrorCollectorConfig Source #
How snap-error-collector should run.
Constructors
| ErrorCollectorConfig | |
Fields
| |
basicConfig :: (UTCTime -> Seq LoggedException -> Int -> IO ()) -> ErrorCollectorConfig Source #
A convenient constructor for ErrorCollectorConfig that collects up to
100 exceptions and flushes the queue every minute. You have to supply the
IO action to run when the queue is flushed.