summaryrefslogtreecommitdiff
path: root/Biz/Log.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Log.hs')
-rw-r--r--Biz/Log.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/Biz/Log.hs b/Biz/Log.hs
index 747efed..9304cf7 100644
--- a/Biz/Log.hs
+++ b/Biz/Log.hs
@@ -13,6 +13,8 @@ module Biz.Log
-- Operators
(~&),
(~?),
+ -- Wai Middleware
+ wai,
-- | Low-level
msg,
br,
@@ -21,6 +23,7 @@ where
import Alpha hiding (pass)
import qualified Data.Text as Text
+import qualified Network.Wai as Wai
import Rainbow (chunk, fore, green, magenta, red, white, yellow)
import qualified Rainbow
import qualified System.Environment as Env
@@ -87,3 +90,14 @@ mark label val =
-- | Conditional mark.
(~?) :: Show a => a -> (a -> Bool) -> Text -> a
(~?) val test label = if test val then mark label val else val
+
+wai :: Wai.Middleware
+wai app req sendResponse =
+ app req <| \res ->
+ info
+ [ str <| Wai.requestMethod req,
+ show <| Wai.remoteHost req,
+ str <| Wai.rawPathInfo req
+ ]
+ >> br
+ >> sendResponse res