Fix run-test on host.
Change-Id: I44ebb4cdc2f5966be51a063e3c7256ab3016c404
diff --git a/src/runtime.cc b/src/runtime.cc
index 12f7c8b..014ce6b 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -22,6 +22,7 @@
#include <cstdlib>
#include <limits>
#include <vector>
+#include <fstream>
#include "class_linker.h"
#include "class_loader.h"
@@ -421,6 +422,15 @@
gLogVerbosity.third_party_jni = true;
} else if (verbose_options[i] == "threads") {
gLogVerbosity.threads = true;
+ } else if (StartsWith(verbose_options[i], "log-to=")) {
+ std::string log_file_name(verbose_options[i].substr(strlen("log-to=")));
+ std::ofstream* log_file = new std::ofstream(log_file_name.c_str());
+ if (log_file->is_open() && log_file->good()) {
+ gLogVerbosity.SetLoggingStream(log_file);
+ } else {
+ LOG(ERROR) << "Fail to open log file: \"" << log_file_name << "\","
+ << " use default logging stream.";
+ }
} else {
LOG(WARNING) << "Ignoring unknown -verbose option: " << verbose_options[i];
}