aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-07-27 18:56:17 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-07-27 18:56:17 +0300
commitf179ab72a8c623383f68eac3e30635700d88dde9 (patch)
tree89a811637d5da018f8d765b294f7200d7dae4727
parenta77942df26b0957aa17f1af16b80358700f02520 (diff)
Make bbot to also print utility logs
-rw-r--r--bbot/worker/worker.cxx27
1 files 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;
}
}