raven-haskell-0.1.0.1: Haskell client for Sentry logging service.

Safe HaskellNone
LanguageHaskell98

System.Log.Raven

Contents

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"

Synopsis

Event service

initRaven Source

Arguments

:: String

Sentry DSN

-> (SentryRecord -> SentryRecord)

Default fields updater. Use id if not needed.

-> (SentrySettings -> SentryRecord -> IO ())

Event transport from Raven.Transport.*

-> (SentryRecord -> IO ())

Fallback handler.

-> IO SentryService

Event service to use in register.

Initialize event service.

disabledRaven :: IO SentryService Source

Disabled service that ignores incoming events.

register Source

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 -> SentryRecord Source

Set culprit field.

tags :: [(String, String)] -> SentryRecord -> SentryRecord Source

Add record tags.

extra :: [(String, String)] -> SentryRecord -> SentryRecord Source

Add record extra information.

Lower level helpers

record Source

Arguments

:: 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.