From 6a67e021019a415b69d5f85bb157c566973413c7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 30 May 2017 20:33:44 +0300 Subject: Extend tracer with process_run() command interface --- bbot/buildfile | 4 ++-- bbot/diagnostics.cxx | 12 ++++++++++++ bbot/diagnostics.hxx | 9 +++++++-- bbot/utility.cxx | 23 ----------------------- bbot/utility.hxx | 3 --- bbot/utility.txx | 6 +++--- bbot/worker.cxx | 2 +- 7 files changed, 25 insertions(+), 34 deletions(-) delete mode 100644 bbot/utility.cxx 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; - // 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 - -#include - -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)...); } - 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 (in), forward (out), forward (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 (in), forward (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 (in), forward (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); -- cgit v1.1