co-log-simple-1.2.0: src/examples/Main.hs
module Main
( main
)
where
import Colog.Monad (usingLoggerT)
import Colog.Simple (Severity (Debug, Notice), (%), (%+), logger,
loggingDisabled, logInfo, logNotice, logTest, logTextStderr, logTextStdout,
msg, msgc, sevc, stack, str, time)
main :: IO ()
main = do
putStrLn "------------------------------------------"
usingLoggerT (logger (sevc %+ msg) logTextStdout Debug) $ do
logNotice "Examples of all Severity values"
logTest
putStrLn "------------------------------------------"
usingLoggerT (logger msgc logTextStderr Notice) $ do
logNotice "Example of a different formatter with Severity set to Notice"
logNotice "These are going to stderr"
logTest
putStrLn "------------------------------------------"
usingLoggerT (logger msg logTextStdout Debug) $ do
logNotice "No colors is possible of course"
logTest
putStrLn "------------------------------------------"
usingLoggerT (logger (time %+ sevc %+ str "| " % msg) logTextStdout Debug) $ do
logNotice "Timestamps are often useful"
logTest
putStrLn "------------------------------------------"
usingLoggerT (logger (sevc %+ msg %+ stack) logTextStdout Debug) $ do
logNotice "With call stack info"
logTest
putStrLn "------------------------------------------"
-- Example of completely turning off logging
usingLoggerT loggingDisabled $
logInfo "This message should never be shown"