Android Open Source - ILog Settings






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;
/*w  w  w .jav  a 2  s  .  c  o  m*/
import com.moshx.ilog.filelogger.FileLogger;

public class Settings {

  public enum Level {

    DEBUG(0x01), INFO(0x02), WARN(0x04), ERROR(0x08), VERBOSE(0x16);

    public final int value;

    Level(int value) {
      this.value = value;

    }
  }

  boolean enabled = true;
  /**
   * Levels
   */
  boolean isDebugEnabled = true;
  boolean isInfoEnabled = true;
  boolean isWarnEnabled = true;
  boolean isErrorEnabled = true;
  boolean isVerboseEnabled = true;
  boolean isFileLoggingEnabled = false;
  private boolean isWrapText = true;

  /**
   * Sets the {@link Level}s that would be logged, only passed levels would be
   * logged.
   * 
   * @param levels
   *            to be logged
   */
  public void setLevels(int levels) {

    isDebugEnabled = ((levels & Level.DEBUG.value) == Level.DEBUG.value);
    isInfoEnabled = ((levels & Level.INFO.value) == Level.INFO.value);
    isWarnEnabled = ((levels & Level.WARN.value) == Level.WARN.value);
    isErrorEnabled = ((levels & Level.ERROR.value) == Level.ERROR.value);
    isVerboseEnabled = ((levels & Level.VERBOSE.value) == Level.VERBOSE.value);
  }

  /**
   * Sets the {@link Level}s that would be logged, only passed levels would be
   * logged.
   * 
   * @param levels
   *            to be logged
   */
  public void setLevels(Level... levels) {
    int vals = 0;
    if (levels != null) {
      for (Level l : levels) {
        vals |= l.value;
      }
      setLevels(vals);
    }
  }

  /**
   * Set the enabled state logging.
   * 
   * @param enabled
   *            True if logging is enabled, false otherwise.
   */
  public void enableLogging(boolean enabled) {
    this.enabled = enabled;
  }

  public boolean isLoggingEnabled() {
    return enabled;
  }

  /**
   * Set the enabled state of the instance of {@link FileLogger} associated
   * with current instance of {@link ILog}.
   * 
   * @param enabled
   *            True if file logging is enabled, false otherwise.
   */
  public void setFileLogging(boolean enabled) {
    isFileLoggingEnabled = enabled;
  }

  public boolean isFileLogging() {
    return isFileLoggingEnabled;
  }

  /**
   * formations
   */

  private String outFormat = "%s   -%s   %s   %s";

  public void setOutFormat(String format) {
    outFormat = format;
  }

  public String formatOut(Object... in) {
    return String.format(outFormat, in);
  }

  public boolean isWrapText() {
    return isWrapText;
  }

  /**
   * enabled text wrapping in Android LogCat, if the length of the message
   * will be more than 4000 characters, it will be split into lines
   * 
   * @param isWrapText
   *            if true text wrapping will be enabled, false otherwise
   *            (default value is enabled)
   */
  public void setWrapText(boolean isWrapText) {
    this.isWrapText = isWrapText;
  }
}




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