{-# LANGUAGE CPP #-}
module Happstack.Server.Internal.LogFormat
( formatTimeCombined
, formatRequestCombined
) where
#if MIN_VERSION_time(1,5,0)
import Data.Time.Format (FormatTime(..), formatTime, defaultTimeLocale)
#else
import Data.Time.Format (FormatTime(..), formatTime)
import System.Locale (defaultTimeLocale)
#endif
formatTimeCombined :: FormatTime t => t -> String
formatTimeCombined :: t -> String
formatTimeCombined = TimeLocale -> String -> t -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale "%d/%b/%Y:%H:%M:%S %z"
formatRequestCombined :: FormatTime t =>
String
-> String
-> t
-> String
-> Int
-> Integer
-> String
-> String
-> String
formatRequestCombined :: String
-> String
-> t
-> String
-> Int
-> Integer
-> String
-> String
-> String
formatRequestCombined host :: String
host user :: String
user time :: t
time requestLine :: String
requestLine responseCode :: Int
responseCode size :: Integer
size referer :: String
referer userAgent :: String
userAgent =
[String] -> String
unwords
[ String
host
, String
user
, "[" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
formattedTime String -> String -> String
forall a. [a] -> [a] -> [a]
++ "]"
, String -> String
forall a. Show a => a -> String
show String
requestLine
, Int -> String
forall a. Show a => a -> String
show Int
responseCode
, Integer -> String
forall a. Show a => a -> String
show Integer
size
, String -> String
forall a. Show a => a -> String
show String
referer
, String -> String
forall a. Show a => a -> String
show String
userAgent
]
where formattedTime :: String
formattedTime = t -> String
forall t. FormatTime t => t -> String
formatTimeCombined t
time