Skip to content

Instantly share code, notes, and snippets.

@hilfritz
Last active June 21, 2018 14:23
Show Gist options
  • Select an option

  • Save hilfritz/08c4fe44dc533ed211b69c49593cff35 to your computer and use it in GitHub Desktop.

Select an option

Save hilfritz/08c4fe44dc533ed211b69c49593cff35 to your computer and use it in GitHub Desktop.
Android Java logger that makes sure the logs are not cut when the string is too long
public class Logger {
public static final void logd(String tag, String message){
Logger.d(tag, message);
}
public static void d(String TAG, String message) {
int maxLogSize = 1000;
for(int i = 0; i <= message.length() / maxLogSize; i++) {
int start = i * maxLogSize;
int end = (i+1) * maxLogSize;
end = end > message.length() ? message.length() : end;
android.util.Log.d(TAG, message.substring(start, end));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment