More debugging output
This commit is contained in:
@@ -21,6 +21,9 @@ import android.os.Bundle;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StreamTokenizer;
|
||||
import java.io.StringReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -53,6 +56,18 @@ public final class Log {
|
||||
}
|
||||
}
|
||||
|
||||
public static void dEscaped(String tag, String msg) {
|
||||
if (Constants.DEBUG) {
|
||||
android.util.Log.d(tag, removeUnicodeAndEscapeChars(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public static void dEscaped(String tag, String msg, Throwable tr) {
|
||||
if (Constants.DEBUG) {
|
||||
android.util.Log.d(tag, removeUnicodeAndEscapeChars(msg), tr);
|
||||
}
|
||||
}
|
||||
|
||||
public static void i(String tag, String msg) {
|
||||
if (Constants.DEBUG) {
|
||||
android.util.Log.i(tag, msg);
|
||||
@@ -116,4 +131,34 @@ public final class Log {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String removeUnicodeAndEscapeChars(String input) {
|
||||
StringBuilder buffer = new StringBuilder(input.length());
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
if ((int) input.charAt(i) > 256) {
|
||||
buffer.append("\\u").append(Integer.toHexString((int) input.charAt(i)));
|
||||
} else {
|
||||
if (input.charAt(i) == '\n') {
|
||||
buffer.append("\\n");
|
||||
} else if (input.charAt(i) == '\t') {
|
||||
buffer.append("\\t");
|
||||
} else if (input.charAt(i) == '\r') {
|
||||
buffer.append("\\r");
|
||||
} else if (input.charAt(i) == '\b') {
|
||||
buffer.append("\\b");
|
||||
} else if (input.charAt(i) == '\f') {
|
||||
buffer.append("\\f");
|
||||
} else if (input.charAt(i) == '\'') {
|
||||
buffer.append("\\'");
|
||||
} else if (input.charAt(i) == '\"') {
|
||||
buffer.append("\\");
|
||||
} else if (input.charAt(i) == '\\') {
|
||||
buffer.append("\\\\");
|
||||
} else {
|
||||
buffer.append(input.charAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user