Skip to content

Functions for logging ToJSON instances with monad-logger

License

Notifications You must be signed in to change notification settings

fpco/monad-logger-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monad Logger functions for JSON

TravisCI Hackage

Install

As a library:

cabal install monad-logger-json

Usage (example)

{-# LANGUAGE TemplateHaskell #-}

import Control.Monad.IO.Class ( MonadIO(liftIO) )
import Control.Monad.Logger ( runStdoutLoggingT )
import Control.Monad.Logger.JSON ( logInfoJ, logDebugJ )
import Data.Aeson.TH ( defaultOptions, deriveJSON )
import Data.Time.Clock ( UTCTime, getCurrentTime )

data Message = Message { time :: UTCTime }

$( deriveJSON defaultOptions ''Message )

main :: IO ()
main =
  runStdoutLoggingT
    (do now <- liftIO getCurrentTime
        $logDebugJ (Message now)
        $logInfoJ "Hello world")

About

Functions for logging ToJSON instances with monad-logger

Resources

License

Stars

Watchers

Forks

Packages

No packages published