Reset the stream state at the end of each line of logging.

The Android logging always behaved like this (because there's a new
underlying std::stringstream each time), but on Linux we were mutating
std::cerr.

Change-Id: I991cb769f783f82aea53ec023e3aea330a1a304c
diff --git a/src/logging.h b/src/logging.h
index 5169e2a..bf6d179 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -124,6 +124,7 @@
 
  private:
   std::stringstream buffer_;
+  std::ios_base::fmtflags stream_state_;
   const char* file_;
   int line_;
   LogSeverity severity_;
diff --git a/src/logging_linux.cc b/src/logging_linux.cc
index aa7dc91..fc16563 100644
--- a/src/logging_linux.cc
+++ b/src/logging_linux.cc
@@ -25,6 +25,7 @@
 LogMessage::LogMessage(const char* file, int line, LogSeverity severity, int error)
 : line_(line), severity_(severity), errno_(error)
 {
+  stream_state_ = stream().flags();
   const char* last_slash = strrchr(file, '/');
   file_ = (last_slash == NULL) ? file : last_slash + 1;
   stream() << StringPrintf("%c %5d %5d %s:%d] ",
@@ -36,6 +37,7 @@
     stream() << ": " << strerror(errno_);
   }
   stream() << std::endl;
+  stream().flags(stream_state_);
   if (severity_ == FATAL) {
     art::Runtime::Abort(file_, line_);
   }