Log a list of objects : Log « Core Class « Android






Log a list of objects

    
//package org.expressme.wireless.game;

import android.util.Log;

class Main {
    private static final String TAG_GAME = "GAME";
  public static void log(Object... objs) {
    if (objs.length == 0) {
      Log.i(TAG_GAME, "");
      return;
    }
    if (objs.length == 1) {
      Object o = objs[0];
      if (o == null) {
        Log.i(TAG_GAME, "(null)");
      } else {
        String s = o.toString();
        int n = s.indexOf('.');
        Log.i(n == (-1) ? TAG_GAME : s.substring(0, n), s);
      }
      return;
    }
    StringBuilder sb = new StringBuilder(128);
    for (Object o : objs) {
      sb.append(o == null ? "(null)" : o.toString());
    }
    String s = sb.toString();
    int n = s.indexOf('.');
    Log.i(n == (-1) ? TAG_GAME : s.substring(0, n), s);
  }
}

   
    
    
    
  








Related examples in the same category

1.Use log
2.Log Utility
3.Log events
4.Log your action
5.Write an activity that looks like a pop-up dialog with a custom theme using a different text color.
6.Responsible for delegating calls to the Android logging system.
7.Dynamically defined), space efficient event logging to help instrument code for large scale stability and performance monitoring.
8.Write Exception Stack to Log
9.Logger and Logger Listener
10.Log Exception trace
11.Utility log tool
12.Debug Util