Log.java revision 08b414ce181f1f14a648ed8e96866197293b2169
1/*
2 * Copyright (C) 2013 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.incallui;
18
19/**
20 * Manages logging for the entire class.
21 */
22public class Log {
23
24    // Generic tag for all In Call logging
25    private static final String TAG = "InCall";
26
27    public static final boolean DEBUG = android.util.Log.isLoggable(TAG, android.util.Log.DEBUG);
28    public static final boolean VERBOSE = android.util.Log.isLoggable(TAG,
29            android.util.Log.VERBOSE);
30    public static final String TAG_DELIMETER = " - ";
31
32    public static void d(String tag, String msg) {
33        if (DEBUG) {
34            android.util.Log.d(TAG, delimit(tag) + msg);
35        }
36    }
37
38    public static void d(Object obj, String msg) {
39        if (DEBUG) {
40            android.util.Log.d(TAG, getPrefix(obj) + msg);
41        }
42    }
43
44    public static void d(Object obj, String str1, Object str2) {
45        if (DEBUG) {
46            android.util.Log.d(TAG, getPrefix(obj) + str1 + str2);
47        }
48    }
49
50    public static void v(Object obj, String msg) {
51        if (VERBOSE) {
52            android.util.Log.v(TAG, getPrefix(obj) + msg);
53        }
54    }
55
56    public static void v(Object obj, String str1, Object str2) {
57        if (VERBOSE) {
58            android.util.Log.d(TAG, getPrefix(obj) + str1 + str2);
59        }
60    }
61
62    public static void e(String tag, String msg, Exception e) {
63        android.util.Log.e(TAG, delimit(tag) + msg, e);
64    }
65
66    public static void e(String tag, String msg) {
67        android.util.Log.e(TAG, delimit(tag) + msg);
68    }
69
70    public static void e(Object obj, String msg, Exception e) {
71        android.util.Log.e(TAG, getPrefix(obj) + msg, e);
72    }
73
74    public static void e(Object obj, String msg) {
75        android.util.Log.e(TAG, getPrefix(obj) + msg);
76    }
77
78    public static void i(String tag, String msg) {
79        android.util.Log.i(TAG, delimit(tag) + msg);
80    }
81
82    public static void i(Object obj, String msg) {
83        android.util.Log.i(TAG, getPrefix(obj) + msg);
84    }
85
86    public static void w(Object obj, String msg) {
87        android.util.Log.w(TAG, getPrefix(obj) + msg);
88    }
89
90    public static void wtf(Object obj, String msg) {
91        android.util.Log.wtf(TAG, getPrefix(obj) + msg);
92    }
93
94    private static String getPrefix(Object obj) {
95        return (obj == null ? "" : (obj.getClass().getSimpleName() + TAG_DELIMETER));
96    }
97
98    private static String delimit(String tag) {
99        return tag + TAG_DELIMETER;
100    }
101}
102