8

The title is pretty self-explanatory. I often add traces when debugging, which requires adding the Debug.Trace import. However, I equally often forget about removing those when I'm done.

What I'd like would be a "dev" switch which would add the import, so that when I disable it I could easily find all of the traces left in the code.

Bartek Banachewicz
  • 38,596
  • 7
  • 91
  • 135
  • 3
    Why not import `trace` from an internal `.Utils` module rather than directly from `Debug.Trace`, and delete the export of `trace` from that module when you are done? – Michael May 19 '16 at 11:00
  • @Michael hah, that's actually a good idea. IOW, should be an answer :) – Bartek Banachewicz May 19 '16 at 11:48
  • Actually, one could craft an "OnOffTrace" module where a compiler flag determined that export. Maybe that's something worth putting on Hackage. I like the Util more in that it looks less intrusive though. However, the *ideal* solution wouldn't require adding any imports at all. – Bartek Banachewicz May 19 '16 at 11:51

1 Answers1

4

Why not import trace from an internal .Utils module rather than directly from Debug.Trace, and delete the export of trace from that module when you are done?

It's different, but another expedient I picked up somewhere is to toggle between trace _ = id and import Debug.Trace (trace). Then you can e.g. go back and forth between using (real) trace and doing things like benchmarking, which is of course wrecked by trace. Then when you are done with all that, you can delete the export of (either) trace and hunt down all the remaining evidence that you ever used it in your project...

Michael
  • 2,889
  • 17
  • 16