summaryrefslogtreecommitdiff
path: root/Utility/WebApp.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-06-11 01:29:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-06-11 01:29:00 -0400
commitbac59cece66e97900554fdee394e8f86027a7d25 (patch)
tree211aabe948cb827ad10b2752865ec1a51ca1def9 /Utility/WebApp.hs
parentf9e7c320eea31ce3cbec647e295d375ac09b7d82 (diff)
Fix build with wai 0.3.0.
This version of wai changed the type of Middleware, so I cannot seem to liftIO inside it. So, got rid of a lot of not really needed complexity to use System.Log.Logger's logging stuff, and just use the standard wai stdout logger when debug logging is enabled. Format may change some, and it logs http to stdout instead of stderr now. Doesn't matter for the webapp since both go to the same log anyway.
Diffstat (limited to 'Utility/WebApp.hs')
-rw-r--r--Utility/WebApp.hs33
1 files changed, 0 insertions, 33 deletions
diff --git a/Utility/WebApp.hs b/Utility/WebApp.hs
index c5e2a439e..0f3378a15 100644
--- a/Utility/WebApp.hs
+++ b/Utility/WebApp.hs
@@ -18,16 +18,12 @@ import qualified Yesod
import qualified Network.Wai as Wai
import Network.Wai.Handler.Warp
import Network.Wai.Handler.WarpTLS
-import Network.Wai.Logger
-import Control.Monad.IO.Class
import Network.HTTP.Types
-import System.Log.Logger
import qualified Data.CaseInsensitive as CI
import Network.Socket
import "crypto-api" Crypto.Random
import qualified Web.ClientSession as CS
import qualified Data.ByteString.Lazy as L
-import qualified Data.ByteString.Lazy.UTF8 as L8
import qualified Data.ByteString as B
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
@@ -158,35 +154,6 @@ getSocket h = do
listen sock maxListenQueue
return sock
-{- Checks if debugging is actually enabled. -}
-debugEnabled :: IO Bool
-debugEnabled = do
- l <- getRootLogger
- return $ getLevel l <= Just DEBUG
-
-{- WAI middleware that logs using System.Log.Logger at debug level.
- -
- - Recommend only inserting this middleware when debugging is actually
- - enabled, as it's not optimised at all.
- -}
-httpDebugLogger :: Wai.Middleware
-httpDebugLogger waiApp req = do
- logRequest req
- waiApp req
-
-logRequest :: MonadIO m => Wai.Request -> m ()
-logRequest req = do
- liftIO $ debugM "WebApp" $ unwords
- [ showSockAddr $ Wai.remoteHost req
- , frombs $ Wai.requestMethod req
- , frombs $ Wai.rawPathInfo req
- --, show $ Wai.httpVersion req
- --, frombs $ lookupRequestField "referer" req
- , frombs $ lookupRequestField "user-agent" req
- ]
- where
- frombs v = L8.toString $ L.fromChunks [v]
-
lookupRequestField :: CI.CI B.ByteString -> Wai.Request -> B.ByteString
lookupRequestField k req = fromMaybe "" . lookup k $ Wai.requestHeaders req