on master help sign in
Merge pull request #257 from yesodweb/red-error-logger

errors should show up as red

commit1c05e8c19f89db56cdc3b7d93321470371a09399 authorMichael Snoyman <michael@snoyman.com> dateFri 23 May 2014, 06:29 (12 years ago) parent97c704ef0b253e
1 file changed+6−9
wai-extra/Network/Wai/Middleware/RequestLogger.hs+6−9
wai-extra/Network/Wai/Middleware/RequestLogger.hs+6−9
@@ -130,11 +130,10 @@ logStdoutDev = unsafePerformIO $ mkRequestLogger def
130130-- no black or white which are expected to be existing terminal colors.
131131colors0 :: [Color]
132132colors0 = [
133− Red
134− , Green
135− , Yellow
136− , Blue
137− , Magenta
133+ Green
134+ , Yellow
135+ , Blue
136+ , Magenta
138137 , Cyan
139138 ]
140139
@@ -170,13 +169,11 @@ rotateColors (c:cs) = (cs ++ [c], c)
170169detailedMiddleware :: Callback -> Bool -> IO Middleware
171170detailedMiddleware cb useColors = do
172171 getAddColor <-
173− if useColors
174− then do
172+ if not useColors then return (return return) else do
175173 icolors <- newIORef colors0
176174 return $ do
177175 color <- liftIO $ atomicModifyIORef icolors rotateColors
178176 return $ ansiColor color
179− else return (return return)
180177 return $ detailedMiddleware' cb getAddColor
181178
182179ansiColor :: Color -> BS.ByteString -> [BS.ByteString]
@@ -279,7 +276,7 @@ detailedMiddleware' cb getAddColor app req = do
279276
280277statusBS :: Response -> [BS.ByteString]
281278statusBS rsp =
282− if status > 400 then ansiColor Red bs else [bs]
279+ if status >= 400 then ansiColor Red bs else [bs]
283280 where
284281 bs = pack $ show status
285282 status = statusCode $ responseStatus rsp