Setup android-base logging in sideload.

Some depending modules (libsnapshot, etc.) uses logging library
from libbase. Make sure those logs are dumped to /tmp/recovery.log.

Test: sideload and view /tmp/recovery.log
Change-Id: I1a27f6345482928684fb9e22494783d2c57016b0
diff --git a/Android.bp b/Android.bp
index 54fd0c2..d6f1090 100644
--- a/Android.bp
+++ b/Android.bp
@@ -339,6 +339,7 @@
         "metrics_reporter_stub.cc",
         "metrics_utils.cc",
         "network_selector_stub.cc",
+        "sideload_logging_android.cc",
         "sideload_main.cc",
         "update_attempter_android.cc",
         "update_boot_flags_action.cc",
diff --git a/sideload_logging_android.cc b/sideload_logging_android.cc
new file mode 100644
index 0000000..f82259f
--- /dev/null
+++ b/sideload_logging_android.cc
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "update_engine/sideload_logging_android.h"
+
+#include <android-base/logging.h>
+
+namespace chromeos_update_engine {
+
+void SetupAndroidLogging(char* argv[]) {
+  android::base::InitLogging(argv, android::base::StdioLogger);
+}
+
+}  // namespace chromeos_update_engine
diff --git a/sideload_logging_android.h b/sideload_logging_android.h
new file mode 100644
index 0000000..0bb8714
--- /dev/null
+++ b/sideload_logging_android.h
@@ -0,0 +1,25 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#pragma once
+
+namespace chromeos_update_engine {
+
+// Some depending modules uses logging functions from android-base.
+// Redirect android-base logging to stdio, which redirects to /tmp/recovery.log.
+void SetupAndroidLogging(char* argv[]);
+
+}  // namespace chromeos_update_engine
diff --git a/sideload_main.cc b/sideload_main.cc
index 818fa5c..29d6f2c 100644
--- a/sideload_main.cc
+++ b/sideload_main.cc
@@ -36,6 +36,7 @@
 #include "update_engine/common/subprocess.h"
 #include "update_engine/common/terminator.h"
 #include "update_engine/common/utils.h"
+#include "update_engine/sideload_logging_android.h"
 #include "update_engine/update_attempter_android.h"
 
 using std::string;
@@ -196,6 +197,7 @@
 
   chromeos_update_engine::Terminator::Init();
   chromeos_update_engine::SetupLogging();
+  chromeos_update_engine::SetupAndroidLogging(argv);
   brillo::FlagHelper::Init(argc, argv, "Update Engine Sideload");
 
   LOG(INFO) << "Update Engine Sideloading starting";