graflog: Monadic correlated log events

[ bsd3, library, logging ] [ Propose Tags ] [ Report a vulnerability ]

Please see README.md


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 1.0.0, 2.0.0, 3.0.0, 4.0.0, 5.0.0, 6.0.0, 6.1.0, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.5
Dependencies aeson, base (>=4.7 && <5), bytestring, containers, mtl, text, text-conversions [details]
License BSD-3-Clause
Copyright 2016 Michael A. Arnold
Author Michael Adlai Arnold
Maintainer marnold@cj.com
Category Logging
Home page https://github.com/m-arnold/graflog#readme
Source repo head: git clone https://github.com/m-arnold/graflog
Uploaded by marnold at 2017-02-15T22:28:37Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 9440 total (35 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-02-15 [all 1 reports]

Readme for graflog-6.1.5

[back to package description]

Graflog

Monadic correlated log events!

##To Use:

  • given a data type:

    data UserSpec = UserSpec
      { email :: Email
      , password :: Text
      , name :: Text
      } deriving (Eq, Show, Generic)
    

    we can create an instance of ToLog:

    instance ToLog UserSpec where
      toLog UserSpec{email, name} =
        dictionary
          [ pair "email" email
          , pair "password" Redacted
          , pair "name" name ]
    

    and derive JSON instances of that:

    deriveJSON defaultOptions ''UserSpec
    

    which can then be logged inside a monad:

    foo = do
      let jimbo = UserSpec (Email "jimbo@gmail.com" ...)
      logJSON $ Event (CorrelationId 0) (EventId 0) "User" (toLog jimbo)
      return jimbo
    
  • you must force stdout to flush after each line, or logs won't appear in a timely manner: call Graflog.Console.enableStdoutLineBuffering at the top of your main function.

  • CorrelationId and EventId generation are not yet supported, so you must create an event manually:

    • inside do notation: let event = Event (CorrelationId 0) (EventId 0)
    • followed at some point by: logJSON $ event (Action "some kind of metadata") (toLog dataToLog)

##To Do:

  • CorrelationId and EventId generation
  • Generic derivation of ToLog / ToJSON instances
  • Support for non-JSON logging?