Safe Haskell | None |
---|---|
Language | Haskell98 |
Raven is a client for Sentry event server (https://www.getsentry.com/).
Start by initializing the raven Service
:
l <- initRaven "https://pub:priv@sentry.hostname.tld:8443/sentry/example_project" id sendRecord stderrFallback
Send events using register
function:
register l "my.logger.name" Debug "Hi there!" id
Tags and stuff can be added using register update functions.
import Data.HashMap.Strict as HM let tags r = r { srTags = HM.insert "spam" "sausage" . HM.insert "eggs" "bacon" . srTags r } lt <- initRaven dsn tags sendRecord stderrFallback let culprit r = r { srCulprit = "my.module.function.name" } register lt "test.culprit" Error "It's a trap!" culprit let extra r = r { srExtra = HM.insert "fnord" "42" $ srExtra r } register lt "test.extra" Info "Test with tags and extra, please ignore."
The core package provides only general interface for sending events which could be wrapped to adapt it to your needs.
let debug msg = forkIO $ register l "my.logger.name" Debug msg (culprit . extra) debug "Async stuff too."
There are some little helpers to compose your own updaters.
You can use them both in initRaven
and register
.
l <- initRaven dsn ( tags [ ("spam", "sausage" , ("eggs", "bacon") ] . extra [ ("more", "stuff") ] ) sendRecord stderrFallback register l "test.helpers" Info "yup, i'm here." $ culprit "java.lang.NotReally"
Synopsis
- initRaven :: String -> (SentryRecord -> SentryRecord) -> (SentrySettings -> SentryRecord -> IO ()) -> (SentryRecord -> IO ()) -> IO SentryService
- disabledRaven :: IO SentryService
- register :: SentryService -> String -> SentryLevel -> String -> (SentryRecord -> SentryRecord) -> IO ()
- stderrFallback :: SentryRecord -> IO ()
- errorFallback :: SentryRecord -> IO ()
- silentFallback :: SentryRecord -> IO ()
- culprit :: String -> SentryRecord -> SentryRecord
- tags :: [(String, String)] -> SentryRecord -> SentryRecord
- extra :: [(String, Value)] -> SentryRecord -> SentryRecord
- record :: String -> SentryLevel -> String -> (SentryRecord -> SentryRecord) -> IO SentryRecord
- recordLBS :: SentryRecord -> ByteString
Event service
:: String | Sentry DSN |
-> (SentryRecord -> SentryRecord) | Default fields updater. Use |
-> (SentrySettings -> SentryRecord -> IO ()) | Event transport from Raven.Transport.* |
-> (SentryRecord -> IO ()) | Fallback handler. |
-> IO SentryService | Event service to use in |
Initialize event service.
disabledRaven :: IO SentryService Source #
Disabled service that ignores incoming events.
:: SentryService | Configured raven service. |
-> String | Logger name. |
-> SentryLevel | Sentry event level. |
-> String | Message. |
-> (SentryRecord -> SentryRecord) | Record updates. |
-> IO () |
Ask service to store an event.
Fallback handlers
stderrFallback :: SentryRecord -> IO () Source #
Show basic message on stderr.
errorFallback :: SentryRecord -> IO () Source #
Crash and burn with record data.
silentFallback :: SentryRecord -> IO () Source #
Ignore recording errors.
Record updaters
culprit :: String -> SentryRecord -> SentryRecord Source #
Set culprit field.
tags :: [(String, String)] -> SentryRecord -> SentryRecord Source #
Add record tags.
extra :: [(String, Value)] -> SentryRecord -> SentryRecord Source #
Add record extra information.
Lower level helpers
:: String | Logger name. |
-> SentryLevel | Level |
-> String | Message |
-> (SentryRecord -> SentryRecord) | Additional options |
-> IO SentryRecord |
Record an event using logging service.
recordLBS :: SentryRecord -> ByteString Source #
JSON-encode record data.