Android Open Source - ILog Android Console






From Project

Back to project page ILog.

License

The source code is released under:

GNU General Public License

If you think the Android project ILog 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 com.moshx.ilog.console;
/*from www.  j  a  v  a  2  s  . c  o  m*/
import android.util.Log;

import com.moshx.ilog.Settings;

class AndroidConsole extends ILogConsole {

  private Settings mSettings;

  public AndroidConsole(Settings sts) {
    mSettings = sts;
  }

  @Override
  public void d(String tag, Object msg, Throwable err) {

    String msgStr = msg != null ? msg.toString() : "";

    if (msgStr.length() > 4000 && mSettings.isWrapText()) {
      String[] arrs = splitStringByLimit(msgStr, 4000);
      for (String s : arrs) {
        Log.d(tag, s);
      }
      if (err != null) {
        Log.d(tag, "", err);
      }
    } else {
      Log.d(tag, msgStr, err);
    }
  }

  @Override
  public void e(String tag, Object msg, Throwable err) {
    String msgStr = msg != null ? msg.toString() : "";

    if (msgStr.length() > 4000 && mSettings.isWrapText()) {
      String[] arrs = splitStringByLimit(msgStr, 4000);
      for (String s : arrs) {
        Log.e(tag, s);
      }
      if (err != null) {
        Log.e(tag, "", err);
      }
    } else {
      Log.e(tag, msgStr, err);
    }
  }

  @Override
  public void i(String tag, Object msg, Throwable err) {

    String msgStr = msg != null ? msg.toString() : "";

    if (msgStr.length() > 4000 && mSettings.isWrapText()) {
      String[] arrs = splitStringByLimit(msgStr, 4000);
      for (String s : arrs) {
        Log.i(tag, s);
      }
      if (err != null) {
        Log.i(tag, "", err);
      }
    } else {
      Log.i(tag, msgStr, err);
    }
  }

  @Override
  public void v(String tag, Object msg, Throwable err) {

    String msgStr = msg != null ? msg.toString() : "";

    if (msgStr.length() > 4000 && mSettings.isWrapText()) {
      String[] arrs = splitStringByLimit(msgStr, 4000);
      for (String s : arrs) {
        Log.v(tag, s);
      }
      if (err != null) {
        Log.v(tag, "", err);
      }
    } else {
      Log.v(tag, msgStr, err);
    }
  }

  @Override
  public void w(String tag, Object msg, Throwable err) {

    String msgStr = msg != null ? msg.toString() : "";

    if (msgStr.length() > 4000 && mSettings.isWrapText()) {
      String[] arrs = splitStringByLimit(msgStr, 4000);
      for (String s : arrs) {
        Log.w(tag, s);
      }
      if (err != null) {
        Log.w(tag, "", err);
      }
    } else {
      Log.w(tag, msgStr, err);
    }
  }

}




Java Source Code List

com.moshx.ilog.ILog.java
com.moshx.ilog.Settings.java
com.moshx.ilog.console.AndroidConsole.java
com.moshx.ilog.console.ConsoleFactory.java
com.moshx.ilog.console.ILogConsole.java
com.moshx.ilog.console.JVMConsole.java
com.moshx.ilog.filelogger.FileLogger.java
com.moshx.ilog.filelogger.HtmlFileLogger.java
com.moshx.ilog.filelogger.TextFileLogger.java
com.moshx.ilog.utils.Utility.java
com.moshx.ilogsample.MainActivity.java
com.moshx.jvmsample.LoggingTest.java