1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.view.textclassifier; 18 19 /** 20 * Logging for android.view.textclassifier package. 21 * <p> 22 * To enable full log: 23 * 1. adb shell setprop log.tag.androidtc VERBOSE 24 * 2. adb shell stop && adb shell start 25 * 26 * @hide 27 */ 28 public final class Log { 29 30 /** 31 * true: Enables full logging. 32 * false: Limits logging to debug level. 33 */ 34 static final boolean ENABLE_FULL_LOGGING = 35 android.util.Log.isLoggable(TextClassifier.DEFAULT_LOG_TAG, android.util.Log.VERBOSE); 36 Log()37 private Log() { 38 } 39 v(String tag, String msg)40 public static void v(String tag, String msg) { 41 if (ENABLE_FULL_LOGGING) { 42 android.util.Log.v(tag, msg); 43 } 44 } 45 d(String tag, String msg)46 public static void d(String tag, String msg) { 47 android.util.Log.d(tag, msg); 48 } 49 w(String tag, String msg)50 public static void w(String tag, String msg) { 51 android.util.Log.w(tag, msg); 52 } 53 e(String tag, String msg, Throwable tr)54 public static void e(String tag, String msg, Throwable tr) { 55 if (ENABLE_FULL_LOGGING) { 56 android.util.Log.e(tag, msg, tr); 57 } else { 58 final String trString = (tr != null) ? tr.getClass().getSimpleName() : "??"; 59 android.util.Log.d(tag, String.format("%s (%s)", msg, trString)); 60 } 61 } 62 } 63