diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-17 14:05:01 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-17 14:05:01 -0800 |
commit | 6042828bdea2a1ed1da1b0d2013a4479fb3d005a (patch) | |
tree | 1b45e4519392e123a7f9daf75ce5d44409877a85 /cpp/001trace.cc | |
parent | 6a2dabe3675cc5d9f03587e1bf4fb8c7a61bafea (diff) | |
download | mu-6042828bdea2a1ed1da1b0d2013a4479fb3d005a.tar.gz |
774 - start persisting test traces
Diffstat (limited to 'cpp/001trace.cc')
-rw-r--r-- | cpp/001trace.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cpp/001trace.cc b/cpp/001trace.cc index 24416a91..0de7c687 100644 --- a/cpp/001trace.cc +++ b/cpp/001trace.cc @@ -86,9 +86,19 @@ ostream& operator<<(ostream& os, unused die) { #define DUMP(layer) cerr << Trace_stream->readable_contents(layer) // Trace_stream is a resource, lease_tracer uses RAII to manage it. +string Trace_file; +static string Trace_dir = ".traces/"; struct lease_tracer { lease_tracer() { Trace_stream = new trace_stream; } - ~lease_tracer() { delete Trace_stream, Trace_stream = NULL; } + ~lease_tracer() { +//? cerr << "write to file? " << Trace_file << "$\n"; //? 1 + if (!Trace_file.empty()) { +//? cerr << "writing\n"; //? 1 + ofstream fout((Trace_dir+Trace_file).c_str()); + fout << Trace_stream->readable_contents(""); + fout.close(); + } + delete Trace_stream, Trace_stream = NULL; Trace_file = ""; } }; #define START_TRACING_UNTIL_END_OF_SCOPE lease_tracer leased_tracer; |