Android Open Source - ILog J V M 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 w w w  .  j  a  v  a  2s  .  c o m
import java.io.PrintStream;

import com.moshx.ilog.Settings;
import com.moshx.ilog.utils.Utility;

class JVMConsole extends ILogConsole {

  private static final String DEBUG_STR = "Debug  ";
  private static final String ERROR_STR = "Error  ";
  private static final String INFO_STR = "Info   ";
  private static final String VERBOSE_STR = "Verbose";
  private static final String WARN_STR = "Warning";

  private Settings mSettings;

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

  @Override
  public void d(String tag, Object msg, Throwable err) {
    System.out.println(mSettings.formatOut(Utility.getFormattedDate(),
        DEBUG_STR, tag, msg != null ? msg : ""));
    printThrowable(err, System.out);
  }

  @Override
  public void e(String tag, Object msg, Throwable err) {
    System.err.println(mSettings.formatOut(Utility.getFormattedDate(),
        ERROR_STR, tag, msg != null ? msg : ""));
    printThrowable(err, System.err);

  }

  @Override
  public void i(String tag, Object msg, Throwable err) {
    System.out.println(mSettings.formatOut(Utility.getFormattedDate(),
        INFO_STR, tag, msg != null ? msg : ""));
    printThrowable(err, System.out);
  }

  @Override
  public void v(String tag, Object msg, Throwable err) {
    System.out.println(mSettings.formatOut(Utility.getFormattedDate(),
        VERBOSE_STR, tag, msg != null ? msg : ""));
    printThrowable(err, System.out);
  }

  @Override
  public void w(String tag, Object msg, Throwable err) {
    System.out.println(mSettings.formatOut(Utility.getFormattedDate(),
        WARN_STR, tag, msg != null ? msg : ""));
    printThrowable(err, System.out);
  }

  private void printThrowable(Throwable err, PrintStream out) {
    if (err != null && out != null) {
      err.printStackTrace(out);
    }
  }
}




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