graflog 4.0.0 → 5.0.0
raw patch · 3 files changed
+17/−14 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Graflog.Logger: instance Data.Aeson.Types.FromJSON.FromJSON Graflog.Logger.Event
- Graflog.Logger: Event :: CorrelationId -> EventId -> Action -> Value -> Event
+ Graflog.Logger: Event :: CorrelationId -> EventId -> Action -> Log -> Event
- Graflog.Logger: [_message] :: Event -> Value
+ Graflog.Logger: [_message] :: Event -> Log
Files
- README.md +1/−10
- graflog.cabal +1/−1
- src/Graflog/Logger.hs +15/−3
README.md view
@@ -1,12 +1,3 @@ # Graflog -In a distributed system, logging is hard. In order for distributed logging to be-useful, it needs to contain metadata about what caused it. Ideally, a given logged-event should tell us:-- what user input caused it-- what API call caused it-- whether it is an error or not-- its severity-- a correlative id that allows us to find other log events related to it--Graflog is primarily focused on the last piece. +Monadic correlated log events!
graflog.cabal view
@@ -1,5 +1,5 @@ name: graflog-version: 4.0.0+version: 5.0.0 synopsis: Monadic correlated log events description: Please see README.md homepage: https://github.com/m-arnold/graflog#readme
src/Graflog/Logger.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE NamedFieldPuns #-} module Graflog.Logger ( Logger(..)@@ -84,12 +85,15 @@ pair :: ToLog a => Text -> a -> (Text, Log) pair key value = (key, toLog value) +redacted :: Text+redacted = "(REDACTED)"+ instance ToJSON Log where toJSON (Message a) = String a toJSON (List a) = toJSON a toJSON (Dictionary a) = toJSON a toJSON (Variant tag values) = toJSON $ Map.fromList [(tag, map toJSON values)]- toJSON Redacted = String "(REDACTED)"+ toJSON Redacted = String redacted class Monad m => Logger m where logEvent :: Event -> m ()@@ -107,9 +111,17 @@ { _correlationId :: CorrelationId , _eventId :: EventId , _action :: Action- , _message :: Value+ , _message :: Log } deriving (Eq, Show)-deriveJSON defaultOptions{fieldLabelModifier = drop 1} ''Event++instance ToJSON Event where+ toJSON Event{_correlationId, _eventId, _action, _message} =+ object+ [ "correlationId" .= _correlationId+ , "eventId" .= _eventId+ , "action" .= _action+ , "message" .= _message+ ] logEvent' :: Console m => Event -> m () logEvent' = writeStdout . jsonEncode