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 17package com.android.services.telephony; 18 19import android.content.Context; 20 21/** 22 * Manages logging for the entire module. 23 */ 24final 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 36 private Log() {} 37 38 public static boolean isLoggable(int level) { 39 return FORCE_LOGGING || android.util.Log.isLoggable(TAG, level); 40 } 41 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 android.telecom.Log.initMd5Sum(); 47 } 48 49 // Relay log messages to Telecom 50 // TODO: Redo namespace of Telephony to use these methods directly. 51 52 public static void d(String prefix, String format, Object... args) { 53 android.telecom.Log.d(prefix, format, args); 54 } 55 56 public static void d(Object objectPrefix, String format, Object... args) { 57 android.telecom.Log.d(objectPrefix, format, args); 58 } 59 60 public static void i(String prefix, String format, Object... args) { 61 android.telecom.Log.i(prefix, format, args); 62 } 63 64 public static void i(Object objectPrefix, String format, Object... args) { 65 android.telecom.Log.i(objectPrefix, format, args); 66 } 67 68 public static void v(String prefix, String format, Object... args) { 69 android.telecom.Log.v(prefix, format, args); 70 } 71 72 public static void v(Object objectPrefix, String format, Object... args) { 73 android.telecom.Log.v(objectPrefix, format, args); 74 } 75 76 public static void w(String prefix, String format, Object... args) { 77 android.telecom.Log.w(prefix, format, args); 78 } 79 80 public static void w(Object objectPrefix, String format, Object... args) { 81 android.telecom.Log.w(objectPrefix, format, args); 82 } 83 84 public static void e(String prefix, Throwable tr, String format, Object... args) { 85 android.telecom.Log.e(prefix, tr, format, args); 86 } 87 88 public static void e(Object objectPrefix, Throwable tr, String format, Object... args) { 89 android.telecom.Log.e(objectPrefix, tr, format, args); 90 } 91 92 public static void wtf(String prefix, Throwable tr, String format, Object... args) { 93 android.telecom.Log.wtf(prefix, tr, format, args); 94 } 95 96 public static void wtf(Object objectPrefix, Throwable tr, String format, Object... args) { 97 android.telecom.Log.wtf(objectPrefix, tr, format, args); 98 } 99 100 public static void wtf(String prefix, String format, Object... args) { 101 android.telecom.Log.wtf(prefix, format, args); 102 } 103 104 public static void wtf(Object objectPrefix, String format, Object... args) { 105 android.telecom.Log.wtf(objectPrefix, format, args); 106 } 107 108 public static String pii(Object pii) { 109 return android.telecom.Log.pii(pii); 110 } 111} 112