lib/debug: deprecate attrNamesToStr, traceXMLVal(Marked)

`attrNamesToStr` is very specific (and pretty trivial), so it doesn’t make sense
to have it in the library.
`traceXMLVal(Marked)` are just a builtin and `trace` and not very useful in
general (trace output should not be parsed anyway).
This commit is contained in:
Profpatsch 2018-04-02 19:13:51 +02:00
parent a7fdd10bf3
commit 7365671fb2

View File

@ -19,9 +19,6 @@ rec {
traceValFn = f: x: trace (f x) x; traceValFn = f: x: trace (f x) x;
traceVal = traceValFn id; traceVal = traceValFn id;
traceXMLVal = x: trace (builtins.toXML x) x;
traceXMLValMarked = str: x: trace (str + builtins.toXML x) x;
# strict trace functions (traced structure is fully evaluated and printed) # strict trace functions (traced structure is fully evaluated and printed)
/* `builtins.trace`, but the value is `builtins.deepSeq`ed first. */ /* `builtins.trace`, but the value is `builtins.deepSeq`ed first. */
@ -55,7 +52,12 @@ rec {
# this can help debug your code as well - designed to not produce thousands of lines # this can help debug your code as well - designed to not produce thousands of lines
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:
trace ( "Warning: `attrNamesToStr` is deprecated "
+ "and will be removed in the next release." )
(lib.concatStringsSep "; " (map (x: "${x}=") (attrNames a)));
showVal = with lib; showVal = with lib;
trace ( "Warning: `showVal` is deprecated " trace ( "Warning: `showVal` is deprecated "
+ "and will be removed in the next release, " + "and will be removed in the next release, "
@ -76,6 +78,15 @@ rec {
(modify x); (modify x);
in go); in go);
traceXMLVal = x:
trace ( "Warning: `traceXMLVal` is deprecated "
+ "and will be removed in the next release." )
(trace (builtins.toXML x) x);
traceXMLValMarked = str: x:
trace ( "Warning: `traceXMLValMarked` is deprecated "
+ "and will be removed in the next release." )
(trace (str + builtins.toXML x) x);
# 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
traceCall = n: f: a: let t = n2: x: traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a)); traceCall = n: f: a: let t = n2: x: traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a));