ART: Add option to use stderr logger

Add a runtime option that sets the android-base logger to StderrLogger,
forcing all further logging to go to stderr. This can be used for
better interaction with dalvikvm or dex2oat on-device.

Bug: 72998814
Test: m test-art-target-gtest-dex2oat_test
Change-Id: I18794bbed0885810f8f0480816b1c780753a9702
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index d0b0d49..f917318 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1667,4 +1667,21 @@
   }
 }
 
+TEST_F(Dex2oatTest, StderrLoggerOutput) {
+  std::string dex_location = GetScratchDir() + "/Dex2OatStderrLoggerTest.jar";
+  std::string odex_location = GetOdexDir() + "/Dex2OatStderrLoggerTest.odex";
+
+  // Test file doesn't matter.
+  Copy(GetDexSrc1(), dex_location);
+
+  GenerateOdexForTest(dex_location,
+                      odex_location,
+                      CompilerFilter::kQuicken,
+                      { "--runtime-arg", "-Xuse-stderr-logger" },
+                      true);
+  // Look for some random part of dex2oat logging. With the stderr logger this should be captured,
+  // even on device.
+  EXPECT_NE(std::string::npos, output_.find("dex2oat took"));
+}
+
 }  // namespace art