[Haskell-cafe] direct-fastcgi and logging

Denis Shevchenko haskell at dshevchenko.biz
Thu Jun 26 07:19:35 UTC 2014

Hi all!

I write a FastCGI-server based on excellent package 'direct-fastcgi' (http://hackage.haskell.org/package/direct-fastcgi). It works perfectly, but I want to inject a logging facility into a handler of requests. For example:

    import Control.Concurrent (forkIO)
    import Network.FastCGI

    main :: IO ()
    main = acceptLoop forkIO handleRequest
    handleRequest :: FastCGI ()
    handleRequest = do
        -- >>> In this place I want to log a message <<<
        setResponseStatus 400
        setResponseHeader HttpContentType "application/json"
        fPutStr "{ "my": "problem_description" }"

Yes, I know about this function in 'Network.FastCGI':

    fLog :: MonadFastCGI m => String -> m ()

but it "logs a message using the web server's logging facility", and I want to log into _my_own_ file. So which solution I can use here? I'd be very grateful for any help.

Sincerely, Denis Shevchenko
haskell at dshevchenko.biz

More information about the Haskell-Cafe mailing list