1 /* 2 * Copyright (C) 2018 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 com.android.textclassifier.common.base; 18 19 /** 20 * Logging for android.view.textclassifier package. 21 * 22 * <p>To enable full log: 23 * 24 * <ul> 25 * <li>adb shell setprop log.tag.androidtc VERBOSE 26 * <li>adb shell stop && adb shell start 27 * </ul> 28 */ 29 public final class TcLog { 30 private static final boolean USE_TC_TAG = true; 31 public static final String TAG = "androidtc"; 32 33 /** true: Enables full logging. false: Limits logging to debug level. */ 34 public static final boolean ENABLE_FULL_LOGGING = 35 android.util.Log.isLoggable(TAG, android.util.Log.VERBOSE); 36 TcLog()37 private TcLog() {} 38 v(String tag, String msg)39 public static void v(String tag, String msg) { 40 if (ENABLE_FULL_LOGGING) { 41 android.util.Log.v(getTag(tag), msg); 42 } 43 } 44 d(String tag, String msg)45 public static void d(String tag, String msg) { 46 android.util.Log.d(getTag(tag), msg); 47 } 48 w(String tag, String msg)49 public static void w(String tag, String msg) { 50 android.util.Log.w(getTag(tag), msg); 51 } 52 e(String tag, String msg, Throwable tr)53 public static void e(String tag, String msg, Throwable tr) { 54 android.util.Log.e(getTag(tag), msg, tr); 55 } 56 getTag(String customTag)57 private static String getTag(String customTag) { 58 return USE_TC_TAG ? TAG : customTag; 59 } 60 } 61