How Do I Output Everything In The Log On Android Without Truncation?
I would like to output a lot of data to my log on Android...but it's truncating the data. How do I prevent it from truncating my logs?
Solution 1:
Logcat truncates data after 4000 characters so you could write it out in chunks:
public static final int LOGCAT_MAX_LINE_LIMIT = 4000;
public static final String TAG = "log_tag";
private void showLog(String message) {
if (message.length() > LOGCAT_MAX_LINE_LIMIT) {
int chunkCount = message.length() / LOGCAT_MAX_LINE_LIMIT;
for (int i = 0; i <= chunkCount; i++) {
int max = LOGCAT_MAX_LINE_LIMIT * (i + 1);
if (max >= message.length()) {
Log.d(TAG, message.substring(LOGCAT_MAX_LINE_LIMIT * i));
} else {
Log.d(TAG, message.substring(LOGCAT_MAX_LINE_LIMIT * i, max));
}
}
} else {
Log.d(TAG, message);
}
}
Post a Comment for "How Do I Output Everything In The Log On Android Without Truncation?"