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 = \msg -> (T.putStrLn . showLogMessage Nothing $ msg)
>> hFlush stdout
, loggerWaitForWrite = hFlush stdout
, loggerShutdown = return ()
}
stdoutLogger :: IO Logger
stdoutLogger = mkLogger "stdout" $ T.putStrLn . showLogMessage Nothing