• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014, 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.services.telephony;
18 
19 import android.content.Context;
20 
21 /**
22  * Manages logging for the entire module.
23  */
24 final public class Log {
25 
26     // Generic tag for all In Call logging
27     private static final String TAG = "Telephony";
28 
29     public static final boolean FORCE_LOGGING = false; /* STOP SHIP if true */
30     public static final boolean DEBUG = isLoggable(android.util.Log.DEBUG);
31     public static final boolean INFO = isLoggable(android.util.Log.INFO);
32     public static final boolean VERBOSE = isLoggable(android.util.Log.VERBOSE);
33     public static final boolean WARN = isLoggable(android.util.Log.WARN);
34     public static final boolean ERROR = isLoggable(android.util.Log.ERROR);
35 
Log()36     private Log() {}
37 
isLoggable(int level)38     public static boolean isLoggable(int level) {
39         return FORCE_LOGGING || android.util.Log.isLoggable(TAG, level);
40     }
41 
initLogging(Context context)42     public static void initLogging(Context context) {
43         // Register Telephony with the Telecom Logger.
44         android.telecom.Log.setTag(TAG);
45         android.telecom.Log.setSessionContext(context);
46     }
47 
48     // Relay log messages to Telecom
49     // TODO: Redo namespace of Telephony to use these methods directly.
50 
d(String prefix, String format, Object... args)51     public static void d(String prefix, String format, Object... args) {
52         android.telecom.Log.d(prefix, format, args);
53     }
54 
d(Object objectPrefix, String format, Object... args)55     public static void d(Object objectPrefix, String format, Object... args) {
56         android.telecom.Log.d(objectPrefix, format, args);
57     }
58 
i(String prefix, String format, Object... args)59     public static void i(String prefix, String format, Object... args) {
60         android.telecom.Log.i(prefix, format, args);
61     }
62 
i(Object objectPrefix, String format, Object... args)63     public static void i(Object objectPrefix, String format, Object... args) {
64         android.telecom.Log.i(objectPrefix, format, args);
65     }
66 
v(String prefix, String format, Object... args)67     public static void v(String prefix, String format, Object... args) {
68         android.telecom.Log.v(prefix, format, args);
69     }
70 
v(Object objectPrefix, String format, Object... args)71     public static void v(Object objectPrefix, String format, Object... args) {
72         android.telecom.Log.v(objectPrefix, format, args);
73     }
74 
w(String prefix, String format, Object... args)75     public static void w(String prefix, String format, Object... args) {
76         android.telecom.Log.w(prefix, format, args);
77     }
78 
w(Object objectPrefix, String format, Object... args)79     public static void w(Object objectPrefix, String format, Object... args) {
80         android.telecom.Log.w(objectPrefix, format, args);
81     }
82 
e(String prefix, Throwable tr, String format, Object... args)83     public static void e(String prefix, Throwable tr, String format, Object... args) {
84         android.telecom.Log.e(prefix, tr, format, args);
85     }
86 
e(Object objectPrefix, Throwable tr, String format, Object... args)87     public static void e(Object objectPrefix, Throwable tr, String format, Object... args) {
88         android.telecom.Log.e(objectPrefix, tr, format, args);
89     }
90 
wtf(String prefix, Throwable tr, String format, Object... args)91     public static void wtf(String prefix, Throwable tr, String format, Object... args) {
92         android.telecom.Log.wtf(prefix, tr, format, args);
93     }
94 
wtf(Object objectPrefix, Throwable tr, String format, Object... args)95     public static void wtf(Object objectPrefix, Throwable tr, String format, Object... args) {
96         android.telecom.Log.wtf(objectPrefix, tr, format, args);
97     }
98 
wtf(String prefix, String format, Object... args)99     public static void wtf(String prefix, String format, Object... args) {
100         android.telecom.Log.wtf(prefix, format, args);
101     }
102 
wtf(Object objectPrefix, String format, Object... args)103     public static void wtf(Object objectPrefix, String format, Object... args) {
104         android.telecom.Log.wtf(objectPrefix, format, args);
105     }
106 
pii(Object pii)107     public static String pii(Object pii) {
108         return android.telecom.Log.pii(pii);
109     }
110 }
111