Getting debugging/logging info?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting debugging/logging info?

Hugh Perkins
In imperative languages we can do this type of thing:

SystemLogging.LogInfo("About to do something...");
DoSomething();
SystemLogging.LogInfo("Did Something");
SystemLogging.LogInfo("x is " + x );

How can we do something similar in Haskell?


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Getting debugging/logging info?

Neil Mitchell
Hi

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

See trace: http://www.haskell.org/hoogle/?q=trace

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Getting debugging/logging info?

Mark T.B. Carroll-2
In reply to this post by Hugh Perkins
"Hugh Perkins" <[hidden email]> 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

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Getting debugging/logging info?

Hugh Perkins

On 7/3/07, Neil Mitchell <[hidden email]> wrote:
See trace: <a href="http://www.haskell.org/hoogle/?q=trace" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.haskell.org/hoogle/?q=trace


I'll check that out.  Thanks.

> Maybe, with System.IO,

Fine in main :-) Less good in a 100,000 line application.


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Getting debugging/logging info?

Mark T.B. Carroll-2
"Hugh Perkins" <[hidden email]> writes:
(snip)
>> Maybe, with System.IO,
>
> Fine in main :-) Less good in a 100,000 line application.

Oh, sorry, I thought your point had been about making sure the operation
was done before the "did something" line got printed. (-:

-- Mark

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Getting debugging/logging info?

Brandon S Allbery KF8NH
In reply to this post by Neil Mitchell

On Jul 2, 2007, at 18:40 , Neil Mitchell wrote:

>> SystemLogging.LogInfo("Did Something");
>> SystemLogging.LogInfo("x is " + x );
>>
>> How can we do something similar in Haskell?
>
> See trace: http://www.haskell.org/hoogle/?q=trace

In addition, you could use the Writer monad to collect log  
information as you perform a computation.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [hidden email]
system administrator [openafs,heimdal,too many hats] [hidden email]
electrical and computer engineering, carnegie mellon university    KF8NH


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Getting debugging/logging info?

Jules Bean
In reply to this post by Hugh Perkins
Hugh Perkins wrote:
> In imperative languages we can do this type of thing:
>
> SystemLogging.LogInfo("About to do something...");
> DoSomething();
> SystemLogging.LogInfo("Did Something");
> SystemLogging.LogInfo("x is " + x );

This is what the Writer Monad is for, probably.

Jules
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Getting debugging/logging info?

Hugh Perkins
Ok, I'll play with that.

On 7/3/07, Jules Bean <[hidden email]> wrote:
Hugh Perkins wrote:
> In imperative languages we can do this type of thing:
>
> SystemLogging.LogInfo("About to do something...");
> DoSomething();
> SystemLogging.LogInfo("Did Something");
> SystemLogging.LogInfo("x is " + x );

This is what the Writer Monad is for, probably.

Jules


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe