Logpublic final class Log extends Object Manages logging for the entire module. |
Fields Summary |
---|
private static final String | TAG | public static final boolean | FORCE_LOGGING | public static final boolean | DEBUG | public static final boolean | INFO | public static final boolean | VERBOSE | public static final boolean | WARN | public static final boolean | ERROR |
Constructors Summary |
---|
private Log()
|
Methods Summary |
---|
private static java.lang.String | buildMessage(java.lang.String prefix, java.lang.String format, java.lang.Object args)
String msg;
try {
msg = (args == null || args.length == 0) ? format
: String.format(Locale.US, format, args);
} catch (IllegalFormatException ife) {
wtf("Log", ife, "IllegalFormatException: formatString='%s' numArgs=%d", format,
args.length);
msg = format + " (An error occurred while formatting the message.)";
}
return String.format(Locale.US, "%s: %s", prefix, msg);
| public static void | d(java.lang.String prefix, java.lang.String format, java.lang.Object args)
if (DEBUG) {
android.util.Log.d(TAG, buildMessage(prefix, format, args));
}
| public static void | d(java.lang.Object objectPrefix, java.lang.String format, java.lang.Object args)
if (DEBUG) {
android.util.Log.d(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
}
| public static void | e(java.lang.String prefix, java.lang.Throwable tr, java.lang.String format, java.lang.Object args)
if (ERROR) {
android.util.Log.e(TAG, buildMessage(prefix, format, args), tr);
}
| public static void | e(java.lang.Object objectPrefix, java.lang.Throwable tr, java.lang.String format, java.lang.Object args)
if (ERROR) {
android.util.Log.e(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args),
tr);
}
| private static java.lang.String | encodeHex(byte[] bytes)
StringBuffer hex = new StringBuffer(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
int byteIntValue = bytes[i] & 0xff;
if (byteIntValue < 0x10) {
hex.append("0");
}
hex.append(Integer.toString(byteIntValue, 16));
}
return hex.toString();
| private static java.lang.String | getPrefixFromObject(java.lang.Object obj)
return obj == null ? "<null>" : obj.getClass().getSimpleName();
| public static void | i(java.lang.String prefix, java.lang.String format, java.lang.Object args)
if (INFO) {
android.util.Log.i(TAG, buildMessage(prefix, format, args));
}
| public static void | i(java.lang.Object objectPrefix, java.lang.String format, java.lang.Object args)
if (INFO) {
android.util.Log.i(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
}
| public static boolean | isLoggable(int level)
return FORCE_LOGGING || android.util.Log.isLoggable(TAG, level);
| public static java.lang.String | pii(java.lang.Object pii)Redact personally identifiable information for production users.
If we are running in verbose mode, return the original string, otherwise
return a SHA-1 hash of the input string.
if (pii == null || VERBOSE) {
return String.valueOf(pii);
}
return "[" + secureHash(String.valueOf(pii).getBytes()) + "]";
| private static java.lang.String | secureHash(byte[] input)
MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
return null;
}
messageDigest.update(input);
byte[] result = messageDigest.digest();
return encodeHex(result);
| public static void | v(java.lang.String prefix, java.lang.String format, java.lang.Object args)
if (VERBOSE) {
android.util.Log.v(TAG, buildMessage(prefix, format, args));
}
| public static void | v(java.lang.Object objectPrefix, java.lang.String format, java.lang.Object args)
if (VERBOSE) {
android.util.Log.v(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
}
| public static void | w(java.lang.Object objectPrefix, java.lang.String format, java.lang.Object args)
if (WARN) {
android.util.Log.w(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args));
}
| public static void | w(java.lang.String prefix, java.lang.String format, java.lang.Object args)
if (WARN) {
android.util.Log.w(TAG, buildMessage(prefix, format, args));
}
| public static void | wtf(java.lang.String prefix, java.lang.Throwable tr, java.lang.String format, java.lang.Object args)
android.util.Log.wtf(TAG, buildMessage(prefix, format, args), tr);
| public static void | wtf(java.lang.Object objectPrefix, java.lang.Throwable tr, java.lang.String format, java.lang.Object args)
android.util.Log.wtf(TAG, buildMessage(getPrefixFromObject(objectPrefix), format, args),
tr);
| public static void | wtf(java.lang.String prefix, java.lang.String format, java.lang.Object args)
String msg = buildMessage(prefix, format, args);
android.util.Log.wtf(TAG, msg, new IllegalStateException(msg));
| public static void | wtf(java.lang.Object objectPrefix, java.lang.String format, java.lang.Object args)
String msg = buildMessage(getPrefixFromObject(objectPrefix), format, args);
android.util.Log.wtf(TAG, msg, new IllegalStateException(msg));
|
|