You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, you can use Network.Wai.Middleware.RequestLogger. It includes a couple default loggers, or you can tweak the configs if you want. As an example:
moduleMainwhereimportNetwork.Wai.Middleware.RequestLogger (logStdout)
importWeb.Scottymain::IO()
main =do
scotty 3000$do
middleware logStdout
...
will produce "prod" type log statements like
Setting phasers to stun... (port 3000) (ctrl-c to quit)
127.0.0.1 - - [08/Jun/2017:18:28:02 -0500] "GET / HTTP/1.1" 200 - "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
127.0.0.1 - - [08/Jun/2017:18:28:02 -0500] "GET /init HTTP/1.1" 404 - "http://localhost:3000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
if you swap in logStdoutDev for logStdout you get more "dev" type log statements like
Setting phasers to stun... (port 3000) (ctrl-c to quit)
GET /
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Status: 200 OK 0.001119s
GET /init
Accept: */*
Status: 404 Not Found 0.000061s
Would it basically be a middleware based on https://hackage.haskell.org/package/wai-extra-3.0.19.1/docs/Network-Wai-Middleware-RequestLogger.html ? Will it also log time taken to complete the request?
The text was updated successfully, but these errors were encountered: