From cec32f193f866ae13a11986ecf5692886ed8554b Mon Sep 17 00:00:00 2001 From: Colin Liang Date: Fri, 15 Dec 2023 19:00:52 -0800 Subject: [PATCH] Add log API for non release builds. (#2108) Make v(),d(),i() logs not print for release builds. These logs still prints for fishfood and dogfood builds. b/315852240 Co-authored-by: Colin Liang --- .../app/src/main/java/dev/cobalt/util/Log.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/util/Log.java b/starboard/android/apk/app/src/main/java/dev/cobalt/util/Log.java index cca7c026185e..5cbb1019da08 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/util/Log.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/util/Log.java @@ -90,15 +90,24 @@ private static int logWithMethod( } public static int v(String tag, String messageTemplate, Object... args) { - return logWithMethod(logV, tag, messageTemplate, args); + if (android.util.Log.isLoggable(TAG, android.util.Log.VERBOSE)) { + return logWithMethod(logV, tag, messageTemplate, args); + } + return 0; } public static int d(String tag, String messageTemplate, Object... args) { - return logWithMethod(logD, tag, messageTemplate, args); + if (android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)) { + return logWithMethod(logD, tag, messageTemplate, args); + } + return 0; } public static int i(String tag, String messageTemplate, Object... args) { - return logWithMethod(logI, tag, messageTemplate, args); + if (android.util.Log.isLoggable(TAG, android.util.Log.INFO)) { + return logWithMethod(logI, tag, messageTemplate, args); + } + return 0; } public static int w(String tag, String messageTemplate, Object... args) {