diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-02-22 18:02:37 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-02-22 18:02:37 +0300 |
commit | 235408636362a8c21752a869a1f603315b0d9e19 (patch) | |
tree | b5fe8357c424ce0fd2c6d1f2df23f298567f6490 | |
parent | 660b1bba9e9a82a64d8e08abaa86136c68ef1511 (diff) |
UTF-8-sanitize command logs
-rw-r--r-- | bbot/worker/worker.cxx | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index f25a287..eb2609d 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -16,6 +16,7 @@ #include <libbutl/b.mxx> #include <libbutl/pager.mxx> +#include <libbutl/utility.mxx> // to_utf8() #include <libbutl/filesystem.mxx> #include <libbutl/string-parser.mxx> @@ -138,14 +139,11 @@ run_cmd (tracer& t, result_status r (result_status::success); - // Log the diagnostics. Also print it to stderr at verbosity level 3 or - // higher. + // UTF-8-sanitize and log the diagnostics. Also print the raw diagnostics + // to stderr at verbosity level 3 or higher. // - auto add = [&log, &t] (const string& s, bool trace = true) + auto add = [&log, &t] (string&& s, bool trace = true) { - log += s; - log += '\n'; - if (verb >= 3) { if (trace) @@ -153,6 +151,11 @@ run_cmd (tracer& t, else text << s; } + + to_utf8 (s, '?'); + + log += s; + log += '\n'; }; { @@ -161,7 +164,6 @@ run_cmd (tracer& t, for (string l; is.peek () != ifdstream::traits_type::eof (); ) { getline (is, l); - add (l, false); // Match the log line with the warning-detecting regular expressions // until the first match. @@ -183,6 +185,8 @@ run_cmd (tracer& t, } } } + + add (move (l), false /* trace */); } } |