[Haskell-cafe] Getting debugging/logging info?

Mark T.B. Carroll mark at ixod.org
Mon Jul 2 18:45:06 EDT 2007


"Hugh Perkins" <hughperkins at gmail.com> writes:

> SystemLogging.LogInfo("About to do something...");
> DoSomething();
> SystemLogging.LogInfo("Did Something");
> SystemLogging.LogInfo("x is " + x );
>
> How can we do something similar in Haskell?

Maybe, with System.IO,

main =
    do log <- openFile "/tmp/log.txt" AppendMode
       hSetBuffering log LineBuffering
       hPutStrLn log "About to do something..."
       x <- return $! product [1 .. 65536]
       hPutStrLn log "did something."
       hPutStrLn log ("x is " ++ show x)
       hClose log

Others may now correct me. (-:

-- Mark



More information about the Haskell-Cafe mailing list