| Safe Haskell | None |
|---|
System.Log.Raven
Description
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"
- 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, String)] -> SentryRecord -> SentryRecord
- record :: String -> SentryLevel -> String -> (SentryRecord -> SentryRecord) -> IO SentryRecord
- recordLBS :: SentryRecord -> ByteString
Event service
Arguments
| :: 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 SentryServiceSource
Disabled service that ignores incoming events.
Arguments
| :: 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 -> SentryRecordSource
Set culprit field.
tags :: [(String, String)] -> SentryRecord -> SentryRecordSource
Add record tags.
extra :: [(String, String)] -> SentryRecord -> SentryRecordSource
Add record extra information.
Lower level helpers
Arguments
| :: String | Logger name. |
| -> SentryLevel | Level |
| -> String | Message |
| -> (SentryRecord -> SentryRecord) | Additional options |
| -> IO SentryRecord |
Record an event using logging service.
recordLBS :: SentryRecord -> ByteStringSource
JSON-encode record data.