{-# LANGUAGE CPP #-}
module Network.Wai.Middleware.RequestLogger.Internal
( getDateGetter
, logToByteString
) where
#if !MIN_VERSION_wai_logger(2, 2, 0)
import Control.Concurrent (forkIO, threadDelay)
import Control.Monad (forever)
#endif
import Data.ByteString (ByteString)
import Network.Wai.Logger (clockDateCacher)
import System.Log.FastLogger (LogStr, fromLogStr)
logToByteString :: LogStr -> ByteString
logToByteString :: LogStr -> ByteString
logToByteString = LogStr -> ByteString
fromLogStr
getDateGetter :: IO ()
-> IO (IO ByteString)
#if !MIN_VERSION_wai_logger(2, 2, 0)
getDateGetter flusher = do
(getter, updater) <- clockDateCacher
_ <- forkIO $ forever $ do
threadDelay 1000000
updater
flusher
#else
getDateGetter :: IO () -> IO (IO ByteString)
getDateGetter IO ()
_ = do
(IO ByteString
getter, IO ()
_) <- IO (IO ByteString, IO ())
clockDateCacher
#endif
forall (m :: * -> *) a. Monad m => a -> m a
return IO ByteString
getter