about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-11-05 22:17:55 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-11-05 22:26:51 -0700
commitbc53f46d46a08e95b424ae280a6e45b1566689fa (patch)
tree3c6c55be8e73fdcc4765408c4420a9c60d758f6f
parent0aa6813b004c8003ff675f52850595bbcc2a66a9 (diff)
downloadmu-bc53f46d46a08e95b424ae280a6e45b1566689fa.tar.gz
3627 - selective dumping a single label
Follow-up to commit 3516.
-rw-r--r--003trace.cc6
-rw-r--r--html/003trace.cc.html6
2 files changed, 10 insertions, 2 deletions
diff --git a/003trace.cc b/003trace.cc
index e874d04f..c4344f2c 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -89,9 +89,11 @@ struct trace_line {
 :(before "End Globals")
 bool Hide_errors = false;
 bool Dump_trace = false;
+string Dump_label = "";
 :(before "End Setup")
 Hide_errors = false;
 Dump_trace = false;
+Dump_label = "";
 
 :(before "End Types")
 // Pre-define some global constants that trace_stream needs to know about.
@@ -137,7 +139,9 @@ void trace_stream::newline() {
   string curr_contents = curr_stream->str();
   if (!curr_contents.empty()) {
     past_lines.push_back(trace_line(curr_depth, trim(curr_label), curr_contents));  // preserve indent in contents
-    if (Dump_trace || (!Hide_errors && curr_label == "error"))
+    if ((!Hide_errors && curr_label == "error")
+        || Dump_trace
+        || (!Dump_label.empty() && curr_label == Dump_label))
       cerr << curr_label << ": " << curr_contents << '\n';
   }
   delete curr_stream;
diff --git a/html/003trace.cc.html b/html/003trace.cc.html
index a5523956..4cfee97a 100644
--- a/html/003trace.cc.html
+++ b/html/003trace.cc.html
@@ -122,9 +122,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
 <span class="Delimiter">:(before &quot;End Globals&quot;)</span>
 <span class="Normal">bool</span> Hide_errors = <span class="Constant">false</span><span class="Delimiter">;</span>
 <span class="Normal">bool</span> Dump_trace = <span class="Constant">false</span><span class="Delimiter">;</span>
+string Dump_label = <span class="Constant">&quot;&quot;</span><span class="Delimiter">;</span>
 <span class="Delimiter">:(before &quot;End Setup&quot;)</span>
 Hide_errors = <span class="Constant">false</span><span class="Delimiter">;</span>
 Dump_trace = <span class="Constant">false</span><span class="Delimiter">;</span>
+Dump_label = <span class="Constant">&quot;&quot;</span><span class="Delimiter">;</span>
 
 <span class="Delimiter">:(before &quot;End Types&quot;)</span>
 <span class="Comment">// Pre-define some global constants that trace_stream needs to know about.</span>
@@ -170,7 +172,9 @@ Dump_trace = <span class="Constant">false</span><span class="Delimiter">;</span>
   string curr_contents = curr_stream<span class="Delimiter">-&gt;</span>str<span class="Delimiter">();</span>
   <span class="Normal">if</span> <span class="Delimiter">(</span>!curr_contents<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span>
     past_lines<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>trace_line<span class="Delimiter">(</span>curr_depth<span class="Delimiter">,</span> trim<span class="Delimiter">(</span>curr_label<span class="Delimiter">),</span> curr_contents<span class="Delimiter">));</span>  <span class="Comment">// preserve indent in contents</span>
-    <span class="Normal">if</span> <span class="Delimiter">(</span>Dump_trace || <span class="Delimiter">(</span>!Hide_errors &amp;&amp; curr_label == <span class="Constant">&quot;error&quot;</span><span class="Delimiter">))</span>
+    <span class="Normal">if</span> <span class="Delimiter">((</span>!Hide_errors &amp;&amp; curr_label == <span class="Constant">&quot;error&quot;</span><span class="Delimiter">)</span>
+        || Dump_trace
+        || <span class="Delimiter">(</span>!Dump_label<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> &amp;&amp; curr_label == Dump_label<span class="Delimiter">))</span>
       cerr &lt;&lt; curr_label &lt;&lt; <span class="Constant">&quot;: &quot;</span> &lt;&lt; curr_contents &lt;&lt; <span class="cSpecial">'\n'</span><span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
   <span class="Normal">delete</span> curr_stream<span class="Delimiter">;</span>