From f179ab72a8c623383f68eac3e30635700d88dde9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 27 Jul 2017 18:56:17 +0300 Subject: Make bbot to also print utility logs --- bbot/worker/worker.cxx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index 199528f..348075b 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -102,16 +102,30 @@ run_cmd (tracer& t, result_status r (result_status::success); - // Log the diagnostics. + // Log the diagnostics. Also print it to STDERR at verbosity level 3 or + // higher. // + auto add = [&log, &t] (const string& s, bool trace = true) + { + log += s; + log += '\n'; + + if (verb >= 3) + { + if (trace) + t << s; + else + text << s; + } + }; + { ifdstream is (move (pipe.in), fdstream_mode::skip); // Skip on exception. for (string l; is.peek () != ifdstream::traits_type::eof (); ) { getline (is, l); - log += l; - log += '\n'; + add (l, false); // Match the log line with the warning-detecting regular expressions // until the first match. @@ -139,18 +153,17 @@ run_cmd (tracer& t, if (pr.wait ()) return r; - log += name; const process_exit& e (*pr.exit); if (e.normal ()) { - log += " exited with code " + to_string (e.code ()) + "\n"; + add (name + " exited with code " + to_string (e.code ())); return result_status::error; } else { - log += " terminated abnormally: " + e.description () + - (e.core () ? " (core dumped)" : "") + "\n"; + add (name + " terminated abnormally: " + e.description () + + (e.core () ? " (core dumped)" : "")); return result_status::abnormal; } } -- cgit v1.1