module Log.Backend.StandardOutput.Bulk
( withBulkStdOutLogger
, withBulkJsonStdOutLogger
) where
import Data.Aeson
import Prelude
import System.IO (hFlush, stdout)
import qualified Data.Text.IO as T
import qualified Data.ByteString.Lazy.Char8 as BSL
import Log.Data
import Log.Logger
import Log.Internal.Logger
withBulkStdOutLogger :: (Logger -> IO r) -> IO r
withBulkStdOutLogger act = do
logger <- mkBulkLogger "stdout-bulk"
(\msgs -> do
mapM_ (T.putStrLn . showLogMessage Nothing) msgs
hFlush stdout
) (return ())
withLogger logger act
withBulkJsonStdOutLogger :: (Logger -> IO r) -> IO r
withBulkJsonStdOutLogger act = do
logger <- mkBulkLogger "stdout-bulk-json"
(\msgs -> do
mapM_ (BSL.putStrLn . encode) msgs
hFlush stdout
) (return ())
withLogger logger act