← ClaudeAtlas

haskell-logginglisted

Add structured logging to a Haskell application using `log-effectful`. Covers severity levels (trace/info/attention — no logError), structured payloads, scoped context via `localData`, composition in `main`, and integration with domain errors. Use when adding logs, designing what to log, configuring log backends (stdout/JSON/ElasticSearch), or explaining why there's no `logError`.
ivelten/claude-haskell-skills · ★ 0 · Data & Documents · score 60
Install: claude install-skill ivelten/claude-haskell-skills
# Logging with `log-effectful` Use [`log-effectful`](https://hackage.haskell.org/package/log-effectful) (with `log-base` as the underlying primitives). It's maintained alongside `effectful` and integrates as a native effect — no `MonadLogger` adapters, no instance gymnastics. Other logging libraries (Katip, Blammo, monad-logger, co-log) are designed for mtl-style stacks; using them with `effectful` means writing or depending on adapter packages, which is friction this skill deliberately avoids. ## Dependencies ```cabal build-depends: , log-effectful ^>=1.0 , log-base ^>=0.12 ``` ## The pattern Logging is just another effect in your effect list. Add `Log :> es` wherever you want to emit logs: ```haskell {-# LANGUAGE OverloadedStrings #-} import Effectful import Effectful.Log import Log (logAttention_, logInfo, logTrace_) import Data.Aeson (object, (.=)) registerUser :: ( UserStore :> es , Log :> es , Error RegistrationError :> es ) => Email -> Eff es User registerUser email = do logTrace_ "Starting registration" existing <- getUser (emailToUserId email) case existing of Just _ -> do logAttention_ ("Duplicate registration attempt: " <> coerce email) throwError (EmailAlreadyExists email) Nothing -> do let user = newUser email saveUser user logInfo "User registered" $ object [ "user_id" .= userId user , "email" .= userEmail user ] pure user ``` Two important convent