BeginPackage["QuantumGroups`Utilities`Debugging`"]

DebugEcho; DebugPrint; DebugEvaluate; DebugSet; 
    DebugPrintHeld;

Begin["`Private`"];

DebugSet[
        x : (True | False)] := ($debugMode = x;)

$debugMode = False;

SetAttributes[DebugEvaluate, {HoldAll}]

DebugEvaluate[x__] := If[$debugMode, Evaluate[x]]

DebugPrint[x__] := 
      If[$debugMode, 
        Print["mem: ", MemoryInUse[], " time: ", TimeUsed[], " ", 
          x]]

SetAttributes[ToStringHeld, HoldFirst]

ToStringHeld[e_] := ToString[HoldForm[e], StandardForm]

SetAttributes[DebugPrintHeld, {HoldAll}]

DebugPrintHeld[x__] := 
      If[$debugMode, 
        Print["mem: ", MemoryInUse[], " time: ", TimeUsed[], " ", 
          ReleaseHold[ToStringHeld /@ Hold[x]]]]

SetAttributes[DebugEcho, {HoldAll}]

DebugEcho[x_] := Module[{r}, r = x; DebugPrint[r]; r]

End[];

EndPackage[];