Last active
June 21, 2018 14:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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