Rlog.java revision a7ab821aa12c9a291ad5086d7eb816932b349ea1
1/*
2 * Copyright (C) 2012 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 android.telephony;
18
19import android.util.Log;
20
21/**
22 * A class to log strings to the RADIO LOG.
23 *
24 * @hide
25 */
26public final class Rlog {
27
28    private Rlog() {
29    }
30
31    public static int v(String tag, String msg) {
32        return Log.println_native(Log.LOG_ID_RADIO, Log.VERBOSE, tag, msg);
33    }
34
35    public static int v(String tag, String msg, Throwable tr) {
36        return Log.println_native(Log.LOG_ID_RADIO, Log.VERBOSE, tag,
37                msg + '\n' + Log.getStackTraceString(tr));
38    }
39
40    public static int d(String tag, String msg) {
41        return Log.println_native(Log.LOG_ID_RADIO, Log.DEBUG, tag, msg);
42    }
43
44    public static int d(String tag, String msg, Throwable tr) {
45        return Log.println_native(Log.LOG_ID_RADIO, Log.DEBUG, tag,
46                msg + '\n' + Log.getStackTraceString(tr));
47    }
48
49    public static int i(String tag, String msg) {
50        return Log.println_native(Log.LOG_ID_RADIO, Log.INFO, tag, msg);
51    }
52
53    public static int i(String tag, String msg, Throwable tr) {
54        return Log.println_native(Log.LOG_ID_RADIO, Log.INFO, tag,
55                msg + '\n' + Log.getStackTraceString(tr));
56    }
57
58    public static int w(String tag, String msg) {
59        return Log.println_native(Log.LOG_ID_RADIO, Log.WARN, tag, msg);
60    }
61
62    public static int w(String tag, String msg, Throwable tr) {
63        return Log.println_native(Log.LOG_ID_RADIO, Log.WARN, tag,
64                msg + '\n' + Log.getStackTraceString(tr));
65    }
66
67    public static int w(String tag, Throwable tr) {
68        return Log.println_native(Log.LOG_ID_RADIO, Log.WARN, tag, Log.getStackTraceString(tr));
69    }
70
71    public static int e(String tag, String msg) {
72        return Log.println_native(Log.LOG_ID_RADIO, Log.ERROR, tag, msg);
73    }
74
75    public static int e(String tag, String msg, Throwable tr) {
76        return Log.println_native(Log.LOG_ID_RADIO, Log.ERROR, tag,
77                msg + '\n' + Log.getStackTraceString(tr));
78    }
79
80    public static int println(int priority, String tag, String msg) {
81        return Log.println_native(Log.LOG_ID_RADIO, priority, tag, msg);
82    }
83
84    public static boolean isLoggable(String tag, int level) {
85        return Log.isLoggable(tag, level);
86    }
87
88    /**
89     * Redact personally identifiable information for production users.
90     * If log tag is loggable in verbose mode, return the original string, otherwise return XXX.
91     */
92    public static String pii(String tag, Object pii) {
93        return (isLoggable(tag, Log.VERBOSE) ? String.valueOf(pii) : "XXX");
94    }
95
96}
97
98