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