From 1d6701ca4c67256fe1d599e020645a9cd65c188d Mon Sep 17 00:00:00 2001
From: Leon Styhre <leon@leonstyhre.com>
Date: Mon, 20 Nov 2023 23:02:41 +0100
Subject: [PATCH] (Android) Added error output if attempting to write to log
 file before it was open

---
 es-core/src/Log.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/es-core/src/Log.cpp b/es-core/src/Log.cpp
index f3d8e65bd..cacab31ed 100644
--- a/es-core/src/Log.cpp
+++ b/es-core/src/Log.cpp
@@ -83,9 +83,16 @@ Log::~Log()
 
     if (!sFile.is_open()) {
         // Not open yet, print to stdout.
+#if defined(__ANDROID__)
+        __android_log_print(
+            ANDROID_LOG_ERROR, nullptr,
+            "Error: Tried to write to log file before it was open, the following won't be logged:");
+        __android_log_print(ANDROID_LOG_ERROR, nullptr, "%s", mOutStringStream.str().c_str());
+#else
         std::cerr << "Error: Tried to write to log file before it was open, "
                      "the following won't be logged:\n";
         std::cerr << mOutStringStream.str();
+#endif
         return;
     }