Skip to content

Commit

Permalink
lib: deprecate some things
Browse files Browse the repository at this point in the history
  • Loading branch information
oxij committed Sep 11, 2018
1 parent c0c8c32 commit 6721581
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
19 changes: 11 additions & 8 deletions lib/debug.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib }:
let
inherit (builtins) attrNames trace substring;
inherit (lib) elem;
inherit (lib) elem deprecate;
in

rec {
Expand Down Expand Up @@ -33,16 +33,19 @@ rec {
# -- DEPRECATED --

attrNamesToStr = a:
trace ( "Warning: `attrNamesToStr` is deprecated "
+ "and will be removed in the next release. "
+ "Please use more specific concatenation "
+ "for your uses (`lib.concat(Map)StringsSep`)." )
deprecate {
failingAfter = "18.03";
what = "attrNamesToStr";
reason = "please use more specific concatenation function for your uses (`lib.concat(Map)StringsSep`)";
}
(lib.concatStringsSep "; " (map (x: "${x}=") (attrNames a)));

addErrorContextToAttrs = attrs:
trace ( "Warning: `addErrorContextToAttrs` is deprecated "
+ "and will be removed in the next release. "
+ "Please use `builtins.addErrorContext` directly." )
deprecate {
failingAfter = "18.03";
what = "addErrorContextToAttrs";
replacement = "builtins.addErrorContext";
}
(lib.mapAttrs (a: v: lib.addErrorContext "while evaluating ${a}" v) attrs);

}
40 changes: 25 additions & 15 deletions lib/logging.nix
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ rec {
traceShowValMarked = str: x: trace (str + showVal x) x;

showVal = with lib;
trace ( "Warning: `showVal` is deprecated "
+ "and will be removed in the next release, "
+ "please use `traceSeqN`" )
deprecate {
failingAfter = "18.03";
what = "showVal";
replacement = "traceSeqN";
}
(let
modify = v:
let pr = f: { __pretty = f; val = v; };
Expand All @@ -202,14 +204,18 @@ rec {
in go);

traceXMLVal = x:
trace ( "Warning: `traceXMLVal` is deprecated "
+ "and will be removed in the next release. "
+ "Please use `traceValFn builtins.toXML`." )
deprecate {
failingAfter = "18.03";
what = "traceXMLVal";
replacement = "traceValFn builtins.toXML";
}
(trace (builtins.toXML x) x);
traceXMLValMarked = str: x:
trace ( "Warning: `traceXMLValMarked` is deprecated "
+ "and will be removed in the next release. "
+ "Please use `traceValFn (x: str + builtins.toXML x)`." )
deprecate {
failingAfter = "18.03";
what = "traceXMLValMarked";
replacement = "traceValFn (x: str + builtins.toXML x)";
}
(trace (str + builtins.toXML x) x);

# trace the arguments passed to function and its result
Expand All @@ -219,9 +225,11 @@ rec {
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));

traceValIfNot = c: x:
trace ( "Warning: `traceValIfNot` is deprecated "
+ "and will be removed in the next release. "
+ "Please use `if/then/else` and `traceValSeq 1`.")
deprecate {
failingAfter = "18.03";
what = "traceValIfNot";
reason = "please use `if/then/else` and `traceValSeq 1` instead";
}
(if c x then true else traceSeq (showVal x) false);

# example: (traceCallXml "myfun" id 3) will output something like
Expand All @@ -230,9 +238,11 @@ rec {
# note: if result doesn't evaluate you'll get no trace at all (FIXME)
# args should be printed in any case
traceCallXml = a:
trace ( "Warning: `traceCallXml` is deprecated "
+ "and will be removed in the next release. "
+ "Please complain if you use the function regularly." )
deprecate {
failingAfter = "18.03";
what = "traceCallXml";
reason = "complain if you use the function regularly";
}
(if !isInt a then
traceCallXml 1 "calling ${a}\n"
else
Expand Down

0 comments on commit 6721581

Please sign in to comment.