diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-05-30 20:33:44 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-05-30 20:34:46 +0300 |
commit | 6a67e021019a415b69d5f85bb157c566973413c7 (patch) | |
tree | 0634cb6b4bf7e23d1b19a89cad51db242a2b06b3 | |
parent | f8b062f808b05daea7f827d85d1989bd705b8e73 (diff) |
Extend tracer with process_run() command interface
-rw-r--r-- | bbot/buildfile | 4 | ||||
-rw-r--r-- | bbot/diagnostics.cxx | 12 | ||||
-rw-r--r-- | bbot/diagnostics.hxx | 9 | ||||
-rw-r--r-- | bbot/utility.cxx | 23 | ||||
-rw-r--r-- | bbot/utility.hxx | 3 | ||||
-rw-r--r-- | bbot/utility.txx | 6 | ||||
-rw-r--r-- | bbot/worker.cxx | 2 |
7 files changed, 25 insertions, 34 deletions
diff --git a/bbot/buildfile b/bbot/buildfile index ccfc837..15ab966 100644 --- a/bbot/buildfile +++ b/bbot/buildfile @@ -34,7 +34,7 @@ if ($cxx.target.class == "linux") {hxx cxx}{ tftp } \ {hxx }{ types } \ {hxx cxx}{ types-parsers } \ - {hxx txx cxx}{ utility } \ + {hxx txx }{ utility } \ {hxx }{ version } \ $libs } @@ -48,7 +48,7 @@ exe{bbot-worker}: \ {hxx cxx}{ diagnostics } \ {hxx }{ types } \ {hxx cxx}{ types-parsers } \ -{hxx txx cxx}{ utility } \ +{hxx txx }{ utility } \ {hxx }{ version } \ $libs diff --git a/bbot/diagnostics.cxx b/bbot/diagnostics.cxx index 5954ad1..b5bd9f8 100644 --- a/bbot/diagnostics.cxx +++ b/bbot/diagnostics.cxx @@ -74,4 +74,16 @@ namespace bbot info.type_ = "<6>"; trace_type = "<7>"; } + + // tracer + // + void tracer:: + operator() (const char* const args[], size_t n) const + { + if (verb >= 3) + { + diag_record dr (*this); + process::print (dr.os, args, n); + } + } } diff --git a/bbot/diagnostics.hxx b/bbot/diagnostics.hxx index 696a912..124e64c 100644 --- a/bbot/diagnostics.hxx +++ b/bbot/diagnostics.hxx @@ -112,10 +112,15 @@ namespace bbot }; using trace_mark = butl::diag_mark<trace_mark_base>; - // using tracer = trace_mark; class tracer: public trace_mark { - public: using trace_mark::trace_mark; + public: + using trace_mark::trace_mark; + + // process_run() command tracer interface. + // + void + operator() (const char* const [], std::size_t) const; }; // fail diff --git a/bbot/utility.cxx b/bbot/utility.cxx deleted file mode 100644 index ea62ac2..0000000 --- a/bbot/utility.cxx +++ /dev/null @@ -1,23 +0,0 @@ -// file : bbot/utility.cxx -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : TBC; see accompanying LICENSE file - -#include <bbot/utility.hxx> - -#include <bbot/diagnostics.hxx> - -using namespace std; -using namespace butl; - -namespace bbot -{ - void - run_trace (tracer& t, const char* cmd[], size_t n) - { - if (verb >= 3) - { - diag_record dr (t); - process::print (dr.os, cmd, n); - } - } -} diff --git a/bbot/utility.hxx b/bbot/utility.hxx index 0506293..7a172a2 100644 --- a/bbot/utility.hxx +++ b/bbot/utility.hxx @@ -101,9 +101,6 @@ namespace bbot t, butl::fdnull (), 2, 2, p, forward<A> (a)...); } - void - run_trace (tracer&, const char*[], size_t); - // The curl process wrapper (command line tracing, etc). // class http_curl: public butl::curl diff --git a/bbot/utility.txx b/bbot/utility.txx index 0eb5d75..c5ac8ff 100644 --- a/bbot/utility.txx +++ b/bbot/utility.txx @@ -28,7 +28,7 @@ namespace bbot try { return butl::process_start ( - [&t] (const char* c[], size_t n) {run_trace (t, c, n);}, + t, forward<I> (in), forward<O> (out), forward<E> (err), @@ -111,7 +111,7 @@ namespace bbot method_type m, const string& url, A&&... options) - : butl::curl ([&t] (const char* c[], size_t n) {run_trace (t, c, n);}, + : butl::curl (t, forward<I> (in), forward<O> (out), 2, // Diagnostics to stderr. @@ -130,7 +130,7 @@ namespace bbot method_type m, const string& url, A&&... options) - : butl::curl ([&t] (const char* c[], size_t n) {run_trace (t, c, n);}, + : butl::curl (t, forward<I> (in), forward<O> (out), 2, // Diagnostics to stderr. diff --git a/bbot/worker.cxx b/bbot/worker.cxx index 1d3e43e..63ccd0f 100644 --- a/bbot/worker.cxx +++ b/bbot/worker.cxx @@ -65,7 +65,7 @@ run_bpkg (tracer& t, string& log, const string& cmd, A&&... a) // auto cmdc = [&t, &log] (const char* c[], size_t n) { - run_trace (t, c, n); + t (c, n); ostringstream os; process::print (os, c, n); |