lib/debug: deprecate & modernize showVal
The code is re-implemented in terms of `generators.toPretty`, but is strictly less general than `traceValSeqN`, so we deprecate it.
This commit is contained in:
parent
a455637d28
commit
a7fdd10bf3
|
@ -56,19 +56,25 @@ rec {
|
||||||
traceShowVal = x: trace (showVal x) x;
|
traceShowVal = x: trace (showVal x) x;
|
||||||
traceShowValMarked = str: x: trace (str + showVal x) x;
|
traceShowValMarked = str: x: trace (str + showVal x) x;
|
||||||
attrNamesToStr = a: lib.concatStringsSep "; " (map (x: "${x}=") (attrNames a));
|
attrNamesToStr = a: lib.concatStringsSep "; " (map (x: "${x}=") (attrNames a));
|
||||||
showVal = x:
|
showVal = with lib;
|
||||||
if isAttrs x then
|
trace ( "Warning: `showVal` is deprecated "
|
||||||
if x ? outPath then "x is a derivation, name ${if x ? name then x.name else "<no name>"}, { ${attrNamesToStr x} }"
|
+ "and will be removed in the next release, "
|
||||||
else "x is attr set { ${attrNamesToStr x} }"
|
+ "please use `traceSeqN`" )
|
||||||
else if isFunction x then "x is a function"
|
(let
|
||||||
else if x == [] then "x is an empty list"
|
modify = v:
|
||||||
else if isList x then "x is a list, first element is: ${showVal (head x)}"
|
let pr = f: { __pretty = f; val = v; };
|
||||||
else if x == true then "x is boolean true"
|
in if isDerivation v then pr
|
||||||
else if x == false then "x is boolean false"
|
(drv: "<δ:${drv.name}:${concatStringsSep ","
|
||||||
else if x == null then "x is null"
|
(attrNames drv)}>")
|
||||||
else if isInt x then "x is an integer `${toString x}'"
|
else if [] == v then pr (const "[]")
|
||||||
else if isString x then "x is a string `${substring 0 50 x}...'"
|
else if isList v then pr (l: "[ ${go (head l)}, … ]")
|
||||||
else "x is probably a path `${substring 0 50 (toString x)}...'";
|
else if isAttrs v then pr
|
||||||
|
(a: "{ ${ concatStringsSep ", " (attrNames a)} }")
|
||||||
|
else v;
|
||||||
|
go = x: generators.toPretty
|
||||||
|
{ allowPrettyValues = true; }
|
||||||
|
(modify x);
|
||||||
|
in go);
|
||||||
|
|
||||||
# trace the arguments passed to function and its result
|
# trace the arguments passed to function and its result
|
||||||
# maybe rewrite these functions in a traceCallXml like style. Then one function is enough
|
# maybe rewrite these functions in a traceCallXml like style. Then one function is enough
|
||||||
|
|
Loading…
Reference in New Issue