simple-log-0.7.0: Simple log for Haskell

Safe HaskellNone
LanguageHaskell2010

System.Log.Simple

Description

Fast start

Create log config:

myCfg = logCfg [("", Info), ("app", Trace), ("app.sub", Debug)]
 

Create log and run log monad

run ∷ IO ()
run = runLog myCfg [handler text (file "out.log")] $ yourFunction
 

Function within log monad:

yourFunction ∷ MonadLog m ⇒ m ()
yourFunction = component "app" $ scope "your" $ do
	sendLog Trace "Hello from your function"
 

Each component can have different level in config, subcomponents are specified with . Components have independent scopes Scopes can be nested and separated with /:

function2 ∷ MonadLog m ⇒ m ()
function2 = component "app.sub" $ scope "foo" $ do
	scope "bar/baz" $ do
		sendLog Info "Component app.sub and scope foobarbaz"
		sendLog Trace "Invisible: app.sub configured with debug level"
	sendLog Info "Same component and scope foo"
	component "module" $ sendLog Info "Component module and root scope"
 

You can update config with updateLogConfig function And change handlers with updateLogHandlers

There're also global logger globalLog, that can be used with runGlobalLog

test ∷ IO ()
test = do
	updateLogHandlers globalLog ([handler text (file "test.log")]:)
	runGlobalLog $ sendLog Info "This will go to test.log too"
 

Documentation

runLogMsgs :: (MonadIO m, MonadMask m) => LogConfig -> LogT m a -> m (a, [Message]) Source #

runLogTexts :: (MonadIO m, MonadMask m) => Converter Text -> LogConfig -> LogT m a -> m (a, [Text]) Source #