{-# 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 :: forall t. FormatTime t => t -> String
formatTimeCombined = forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%d/%b/%Y:%H:%M:%S %z"
formatRequestCombined :: FormatTime t =>
String
-> String
-> t
-> String
-> Int
-> Integer
-> String
-> String
-> String
formatRequestCombined :: forall t.
FormatTime t =>
String
-> String
-> t
-> String
-> Int
-> Integer
-> String
-> String
-> String
formatRequestCombined String
host String
user t
time String
requestLine Int
responseCode Integer
size String
referer String
userAgent =
[String] -> String
unwords
[ String
host
, String
user
, String
"[" forall a. [a] -> [a] -> [a]
++ String
formattedTime forall a. [a] -> [a] -> [a]
++ String
"]"
, forall a. Show a => a -> String
show String
requestLine
, forall a. Show a => a -> String
show Int
responseCode
, forall a. Show a => a -> String
show Integer
size
, forall a. Show a => a -> String
show String
referer
, forall a. Show a => a -> String
show String
userAgent
]
where formattedTime :: String
formattedTime = forall t. FormatTime t => t -> String
formatTimeCombined t
time