How to configure logging?

16 views
Skip to first unread message

Alexander Danilov

unread,
Oct 23, 2013, 1:50:36 PM10/23/13
to clck...@googlegroups.com
I would like to configure request/response logging (to console for beginning), what's the simple way for this?


Jeremy Shaw

unread,
Oct 23, 2013, 2:32:07 PM10/23/13
to clck...@googlegroups.com
Good logging support in clckwrks is not yet implemented. if you are
willing to hack your core clckwrks library a bit you could add a
function like logomatic in this example:

module Main where

import Control.Monad.Trans (liftIO)
import Happstack.Server


main :: IO ()
main = simpleHTTP nullConf $ logomatic $ impl

logomatic :: ServerPart Response -> ServerPart Response
logomatic sp =
do req <- askRq
liftIO $ print req
res <- sp
liftIO $ print res
return res

impl :: ServerPart Response
impl =
nullDir >> (ok $ toResponse "Hello, World!")
> --
> You received this message because you are subscribed to the Google Groups
> "clckwrks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clckwrks+u...@googlegroups.com.
> To post to this group, send email to clck...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clckwrks/811fa955-86f6-4449-b84d-a8b7049f4a05%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Alexander Danilov

unread,
Oct 23, 2013, 2:46:27 PM10/23/13
to clck...@googlegroups.com
On 23.10.2013 22:32, Jeremy Shaw wrote:
> Good logging support in clckwrks is not yet implemented. if you are
> willing to hack your core clckwrks library a bit you could add a
> function like logomatic in this example:
>
> module Main where
>
> import Control.Monad.Trans (liftIO)
> import Happstack.Server
>
>
> main :: IO ()
> main = simpleHTTP nullConf $ logomatic $ impl
>
> logomatic :: ServerPart Response -> ServerPart Response
> logomatic sp =
> do req <- askRq
> liftIO $ print req
> res <- sp
> liftIO $ print res
> return res
>
> impl :: ServerPart Response
> impl =
> nullDir >> (ok $ toResponse "Hello, World!")
>
>
>

I understand the idea, thank you.


Reply all
Reply to author
Forward
0 new messages