-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | A logging system for WAI
--   
--   A logging system for WAI
@package wai-logger
@version 0.3.1

module Network.Wai.Logger.Utils

-- | A type for IP address in numeric string representation.
type NumericAddress = String

-- | Convert SockAddr to NumericAddress. If the address is an
--   IPv4-embedded IPv6 address, the IPv4 is extracted.
showSockAddr :: SockAddr -> NumericAddress

module Network.Wai.Logger.Format

-- | Source from which the IP source address of the client is obtained.
data IPAddrSource

-- | From the peer address of the HTTP connection.
FromSocket :: IPAddrSource

-- | From X-Real-IP: or X-Forwarded-For: in the HTTP header.
FromHeader :: IPAddrSource

-- | Apache style log format.
apacheFormat :: IPAddrSource -> ZonedDate -> Request -> Status -> Maybe Integer -> [LogStr]

-- | Apache style log format with Builder. This is experimental.
--   This would replace apacheFormat someday.
apacheFormatBuilder :: IPAddrSource -> ZonedDate -> Request -> Status -> Maybe Integer -> Builder

-- | Logging system for WAI applications.
--   
--   Sample code:
--   
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   module Main where
--   
--   import Blaze.ByteString.Builder (fromByteString)
--   import Control.Monad.IO.Class (liftIO)
--   import Data.ByteString.Char8
--   import Network.HTTP.Types (status200)
--   import Network.Wai
--   import Network.Wai.Handler.Warp
--   import Network.Wai.Logger
--   
--   main :: IO ()
--   main = do
--       aplogger <- stdoutApacheLoggerInit FromSocket True
--       run 3000 $ logapp aplogger
--   
--   logapp :: ApacheLogger -> Application
--   logapp aplogger req = do
--       let status = status200
--           len = 4
--       liftIO $ aplogger req status (Just len)
--       return $ ResponseBuilder status
--           [("Content-Type", "text/plain")
--           ,("Content-Length", pack (show len))]
--           $ fromByteString "PONG"
--   
module Network.Wai.Logger

-- | Apache style logger for WAI
type ApacheLogger = Request -> Status -> Maybe Integer -> IO ()

-- | Obtaining Apache style logger to stdout
stdoutApacheLoggerInit :: IPAddrSource -> Bool -> IO ApacheLogger

-- | Obtaining Apache style logger to stdout
stdoutApacheLoggerInit2 :: IPAddrSource -> Bool -> (DateCacheGetter, DateCacheCloser) -> IO ApacheLogger
