How to best add logging/debugging code?

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Mon Nov 17 08:18:37 EST 2003


Ben Escoto wrote:
> Hi all, does anyone have any tips on how to insert debugging or
> logging statements through a program?  Here are two possibilities:

another thing I found quite useful is
to add a component  { .. , info :: Doc } to my data types,
and then set its value at each function call:

f x y = ( ... ) { info = parens $ fsep [ text "f", info x, info y ] }

( I figure this is sort of part of what
some tools can do automatically? )

that way you always know who built what.
and it's cheap - if you don't use this information,
then it's never created (due to laziness).

best regards,
-- 
-- Johannes Waldmann,  Tel/Fax: (0341) 3076 6479 / 6480 --
------ http://www.imn.htwk-leipzig.de/~waldmann/ ---------




More information about the Haskell mailing list