summary refs log tree commit diff
path: root/pkgs/lib/debug.nix
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2009-03-25 13:48:55 +0000
committerMarc Weber <marco-oweber@gmx.de>2009-03-25 13:48:55 +0000
commite06491168bf7dc9d98c64248ad9e32a70b8dd09a (patch)
treee031a2e0097f3d3fb6a08558235788b3d6f5e0cd /pkgs/lib/debug.nix
parente1c1ecf33aa65568890f04f2b6a47f987107cd3a (diff)
downloadnixpkgs-e06491168bf7dc9d98c64248ad9e32a70b8dd09a.tar
nixpkgs-e06491168bf7dc9d98c64248ad9e32a70b8dd09a.tar.gz
nixpkgs-e06491168bf7dc9d98c64248ad9e32a70b8dd09a.tar.bz2
nixpkgs-e06491168bf7dc9d98c64248ad9e32a70b8dd09a.tar.lz
nixpkgs-e06491168bf7dc9d98c64248ad9e32a70b8dd09a.tar.xz
nixpkgs-e06491168bf7dc9d98c64248ad9e32a70b8dd09a.tar.zst
nixpkgs-e06491168bf7dc9d98c64248ad9e32a70b8dd09a.zip
tidied up pkgs/lib/debug.nix
more consistent naming:
  debugVal -> traceVal
  debugXMLVal -> traceXMLVal

  whatis -> showVal
  traceWhatis -> traceShowVal
  traceMarked -> traceShowValMarked

removed some parenthesis

svn path=/nixpkgs/trunk/; revision=14701
Diffstat (limited to 'pkgs/lib/debug.nix')
-rw-r--r--pkgs/lib/debug.nix32
1 files changed, 16 insertions, 16 deletions
diff --git a/pkgs/lib/debug.nix b/pkgs/lib/debug.nix
index 55d6a0d1b65..ce38259725e 100644
--- a/pkgs/lib/debug.nix
+++ b/pkgs/lib/debug.nix
@@ -14,27 +14,27 @@ rec {
 
   addErrorContextToAttrs = lib.mapAttrs (a : v : lib.addErrorContext "while evaluating ${a}" v);
 
-  debugVal = if builtins ? trace then x: (builtins.trace x x) else x: x;
-  debugXMLVal = if builtins ? trace then x: (builtins.trace (builtins.toXML x) x) else x: x;
+  traceVal = if builtins ? trace then x: (builtins.trace x x) else x: x;
+  traceXMLVal = if builtins ? trace then x: (builtins.trace (builtins.toXML x) x) else x: x;
 
   # this can help debug your code as well - designed to not produce thousands of lines
-  traceWhatis = x : __trace (whatis x) x;
-  traceMarked = str: x: __trace (str + (whatis x)) x;
+  traceShowVal = x : __trace (showVal x) x;
+  traceShowValMarked = str: x: __trace (str + showVal x) x;
   attrNamesToStr = a : lib.concatStringsSep "; " (map (x : "${x}=") (__attrNames a));
-  whatis = x :
-      if (__isAttrs x) then
-          if (x ? outPath) then "x is a derivation, name ${if x ? name then x.name else "<no name>"}, { ${attrNamesToStr x} }"
+  showVal = x :
+      if __isAttrs x then
+          if x ? outPath then "x is a derivation, name ${if x ? name then x.name else "<no name>"}, { ${attrNamesToStr x} }"
           else "x is attr set { ${attrNamesToStr x} }"
-      else if (__isFunction x) then "x is a function"
-      else if (x == []) then "x is an empty list"
-      else if (__isList x) then "x is a list, first item is : ${whatis (__head x)}"
-      else if (x == true) then "x is boolean true"
-      else if (x == false) then "x is boolean false"
-      else if (x == null) then "x is null"
+      else if __isFunction x then "x is a function"
+      else if x == [] then "x is an empty list"
+      else if __isList x then "x is a list, first item is : ${showVal (__head x)}"
+      else if x == true then "x is boolean true"
+      else if x == false then "x is boolean false"
+      else if x == null then "x is null"
       else "x is probably a string starting, starting characters: ${__substring 0 50 x}..";
   # trace the arguments passed to function and its result 
-  traceCall  = n : f : a : let t = n2 : x : traceMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a));
-  traceCall2 = n : f : a : b : let t = n2 : x : traceMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b));
-  traceCall3 = n : f : a : b : c : let t = n2 : x : traceMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b) (t "arg 3" c));
+  traceCall  = n : f : a : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a));
+  traceCall2 = n : f : a : b : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b));
+  traceCall3 = n : f : a : b : c : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b) (t "arg 3" c));
 
 }