Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see long texts/msg in logcat?

Tags:

Since we are using logcat as a console for android. There are cases when the the output text/msg is kinda big and I can't see the complete output. The log cat shows only the starting part of it. Is there a way to expand it so that I can see the full msg?

like image 583
Bohemian Avatar asked Jan 04 '10 06:01

Bohemian


People also ask

How do I view logs on Android emulator?

To access it, open the Chrome Developer tools from the More tools menu. Inside it you need to open the Remote devices view from the More tools menu. The view will list all attached Android devices and running emulator instances, each with its own list of active web views.


1 Answers

This is the way I solved the problem. Hope it helps.

The important method for using it inside your code is splitAndLog.

public class Utils {     /**      * Divides a string into chunks of a given character size.      *       * @param text                  String text to be sliced      * @param sliceSize             int Number of characters      * @return  ArrayList<String>   Chunks of strings      */     public static ArrayList<String> splitString(String text, int sliceSize) {         ArrayList<String> textList = new ArrayList<String>();         String aux;         int left = -1, right = 0;         int charsLeft = text.length();         while (charsLeft != 0) {             left = right;             if (charsLeft >= sliceSize) {                 right += sliceSize;                 charsLeft -= sliceSize;             }             else {                 right = text.length();                 aux = text.substring(left, right);                 charsLeft = 0;             }             aux = text.substring(left, right);             textList.add(aux);         }         return textList;     }      /**      * Divides a string into chunks.      *       * @param text                  String text to be sliced      * @return  ArrayList<String>         */     public static ArrayList<String> splitString(String text) {         return splitString(text, 80);     }      /**      * Divides the string into chunks for displaying them      * into the Eclipse's LogCat.      *       * @param text      The text to be split and shown in LogCat      * @param tag       The tag in which it will be shown.      */     public static void splitAndLog(String tag, String text) {         ArrayList<String> messageList = Utils.splitString(text);         for (String message : messageList) {             Log.d(tag, message);         }     } } 
like image 170
reefaktor Avatar answered Mar 03 '23 13:03

reefaktor