UM: Dump the EvaluationContext when evaluation of a policy fails.
This gives the log reader a complete picture of the state of variables
at the time when a policy evaluation has failed.
We slightly revise the JSON output of EvaluationContext::DumpContext()
to remove trailing whitespaces (newline, etc).
BUG=chromium:387937
TEST=Observed context dumping during unit testing.
Change-Id: I33712a896225f3be97bc313468f89f9cd724673b
Reviewed-on: https://chromium-review.googlesource.com/205896
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/update_manager/evaluation_context.cc b/update_manager/evaluation_context.cc
index eab0fea..2f827c1 100644
--- a/update_manager/evaluation_context.cc
+++ b/update_manager/evaluation_context.cc
@@ -9,6 +9,7 @@
#include <base/bind.h>
#include <base/json/json_writer.h>
+#include <base/strings/string_util.h>
#include <base/values.h>
#include "update_engine/utils.h"
@@ -186,6 +187,7 @@
base::JSONWriter::WriteWithOptions(&value,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json_str);
+ base::TrimWhitespaceASCII(json_str, base::TRIM_TRAILING, &json_str);
return json_str;
}