Disable textclassifier logging in release builds. am: 44742a4b41
am: 1a5a63cdbf

Change-Id: Ic435181dcab7c3ffe408730395d565ecec50aa62
diff --git a/Android.mk b/Android.mk
index 43e56c1..b6a7c40 100644
--- a/Android.mk
+++ b/Android.mk
@@ -31,6 +31,11 @@
     -Wno-undefined-var-template \
     -fvisibility=hidden
 
+# Only enable debug logging in userdebug/eng builds.
+ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
+  MY_LIBTEXTCLASSIFIER_CFLAGS += -DTC_DEBUG_LOGGING=1
+endif
+
 # ------------------------
 # libtextclassifier_protos
 # ------------------------
diff --git a/util/base/logging_raw.cc b/util/base/logging_raw.cc
index 66fdf99..8e0eb1b 100644
--- a/util/base/logging_raw.cc
+++ b/util/base/logging_raw.cc
@@ -50,6 +50,12 @@
 void LowLevelLogging(LogSeverity severity, const std::string& tag,
                      const std::string& message) {
   const int android_log_level = GetAndroidLogLevel(severity);
+#if !defined(TC_DEBUG_LOGGING)
+  if (android_log_level != ANDROID_LOG_ERROR &&
+      android_log_level != ANDROID_LOG_FATAL) {
+    return;
+  }
+#endif
   __android_log_write(android_log_level, tag.c_str(), message.c_str());
 }