Android Open Source - tdpforce L






From Project

Back to project page tdpforce.

License

The source code is released under:

Apache License

If you think the Android project tdpforce listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.telugudesam.cadre.util;
// www  .j  a v  a2 s  . com
import org.json.JSONObject;
import org.telugudesam.cadre.BuildConfig;

import android.content.SharedPreferences;
import android.support.v4.util.LruCache;
import android.util.Log;

import com.google.gson.Gson;

/**
 * GreenLogger class Features: <br>
 * 1. Logging is made easy and manageable <br>
 * 2. Turns off debug/verbose logs on production builds.<br>
 * 3. Easy log filtering on production devices. <br>
 * Filter by "GreenLogger" on adb logcat. <br>
 * (Usage: adb logcat | grep GreenLo)
 * 
 * @author gopinath
 * 
 */
public class L {

  public enum LOG_LEVEL {
    VERBOSE, DEBUG, INFO, WARN, ERROR
  }

  static LruCache<Integer, String> logs = new LruCache<Integer, String>(200);
  static int logIndex = 0;

  public static final LOG_LEVEL logLEVEL = (BuildConfig.DEBUG) ? LOG_LEVEL.VERBOSE
      : LOG_LEVEL.ERROR;
  private static final String TAG = "GreenLogger";

  public static void v(String message) {
    if (L.logLEVEL.ordinal() <= LOG_LEVEL.VERBOSE.ordinal()) {
      Log.v(TAG,
          Thread.currentThread().getStackTrace()[3].getFileName()
              + "["
              + Thread.currentThread().getStackTrace()[3]
                  .getLineNumber() + "]:" + message);
    } else {
      logs.put(logIndex++, message);
      if (logIndex >= logs.maxSize()) {
        logIndex = 0;
      }
    }
  }

  public static void d(String message) {
    if (L.logLEVEL.ordinal() <= LOG_LEVEL.DEBUG.ordinal()) {
      Log.d(TAG,
          Thread.currentThread().getStackTrace()[3].getFileName()
              + "["
              + Thread.currentThread().getStackTrace()[3]
                  .getLineNumber() + "]:" + message);
    }
  }

  public static void i(String message) {
    if (L.logLEVEL.ordinal() <= LOG_LEVEL.INFO.ordinal()) {
      Log.i(TAG, message);
    }
  }

  public static void w(String message) {
    if (L.logLEVEL.ordinal() <= LOG_LEVEL.WARN.ordinal()) {
      Log.w(TAG, message);
    }
  }

  public static void e(String message) {
    if (L.logLEVEL.ordinal() <= LOG_LEVEL.ERROR.ordinal()) {
      Log.e(TAG, message);
    }
  }

  public static void constructEvent(String category, String action,
      String label, String value) {
    Log.v(TAG + "ana" + category, action + " label: " + label
        + " , value = " + value);

  }

  /**
   * Prints the sharedpreferences file passed to this app.
   * 
   * @param mPrefs
   */
  public static void print(SharedPreferences mPrefs) {
    v(new Gson().toJson(mPrefs.getAll()));
  }

  public static void v(String tag, String notifMsg) {
    v(tag + notifMsg);
  }

  public static void print(String string, SharedPreferences sharedPreferences) {
    L.d(string);
    L.print(sharedPreferences);
  }

  /**
   * Prints the given exception so that it can be captured using GreenLogger
   * tag.
   * 
   * @param e
   */
  public static void print(Exception e) {
    if (e != null) {
      L.d("Exception: " + Log.getStackTraceString(e));
    } else
      L.d("exception which is null");

  }

  public static void v(JSONObject jsonObject) {
    L.v(jsonObject.toString());
  }

  public static void d(String tag, String msg) {
    d(tag + msg);
  }

  public static String getProdLogs() {
    return new JSONObject(logs.snapshot()).toString();
  }

  public static void print(String extraInfo, Exception e) {
    if (e != null) {
      L.e(extraInfo + " : " + Log.getStackTraceString(e));
    } else {
      e(extraInfo + " : null exception");
    }
  }

  public static void d(Object anyObject) {
    L.d(new Gson().toJson(anyObject));
  }

}




Java Source Code List

com.etsy.android.grid.ClassLoaderSavedState.java
com.etsy.android.grid.ExtendableListView.java
com.etsy.android.grid.HeaderViewListAdapter.java
com.etsy.android.grid.StaggeredGridView.java
com.etsy.android.grid.util.DynamicHeightImageView.java
com.etsy.android.grid.util.DynamicHeightTextView.java
com.polites.android.Animation.java
com.polites.android.Animator.java
com.polites.android.FlingAnimationListener.java
com.polites.android.FlingAnimation.java
com.polites.android.FlingListener.java
com.polites.android.GestureImageViewListener.java
com.polites.android.GestureImageViewTouchListener.java
com.polites.android.GestureImageView.java
com.polites.android.MathUtils.java
com.polites.android.MoveAnimationListener.java
com.polites.android.MoveAnimation.java
com.polites.android.VectorF.java
com.polites.android.ZoomAnimationListener.java
com.polites.android.ZoomAnimation.java
com.readystatesoftware.systembartint.SystemBarTintManager.java
org.telugudesam.cadre.App.java
org.telugudesam.cadre.Config.java
org.telugudesam.cadre.Constants.java
org.telugudesam.cadre.activity.BaseTdpActivity.java
org.telugudesam.cadre.activity.ConversionCounterActivity.java
org.telugudesam.cadre.activity.ConversionRegistrationActivity.java
org.telugudesam.cadre.activity.PreviewActivity.java
org.telugudesam.cadre.activity.TdpMainActivity.java
org.telugudesam.cadre.adapters.DevelopmentCardsAdapter.java
org.telugudesam.cadre.components.MemCache.java
org.telugudesam.cadre.database.DbHelper.java
org.telugudesam.cadre.database.DbUtils.java
org.telugudesam.cadre.database.Tdp_cadre_boxFactory.java
org.telugudesam.cadre.fragments.DevelopmentCardsFragment.java
org.telugudesam.cadre.objects.DevelopmentCard.java
org.telugudesam.cadre.objects.Events.java
org.telugudesam.cadre.objects.Section.java
org.telugudesam.cadre.objects.dao.DevelopmentCardDao.java
org.telugudesam.cadre.objects.dao.DevelopmentCardTable.java
org.telugudesam.cadre.util.L.java
org.telugudesam.cadre.util.SystemUiHiderBase.java
org.telugudesam.cadre.util.SystemUiHiderHoneycomb.java
org.telugudesam.cadre.util.SystemUiHider.java
org.telugudesam.cadre.util.Utils.java