module Log.Backend.StandardOutput (
simpleStdoutLogger
, stdoutLogger
, withSimpleStdOutLogger
) where
import Prelude
import qualified Data.Text.IO as T
import System.IO
import Log.Data
import Log.Internal.Logger
import Log.Logger
withSimpleStdOutLogger :: (Logger -> IO r) -> IO r
withSimpleStdOutLogger act = do
logger <- stdoutLogger
withLogger logger act
simpleStdoutLogger :: Logger
simpleStdoutLogger = Logger {
loggerWriteMessage = T.putStrLn . showLogMessage Nothing
, loggerWaitForWrite = hFlush stdout
, loggerShutdown = return ()
}
stdoutLogger :: IO Logger
stdoutLogger = mkLogger "stdout" $ T.putStrLn . showLogMessage Nothing