iLog v0.1 is here

ILog is a simple logging library for both Android and JavaSE platforms.

ILog Levels:

  • DEBUG
  • INFO
  • WARN
  • ERROR
  • VERBOSE

ILog Main Features:

  • Works on both Android and JavaSE platforms.
  • File Logging (Text or Html or your own format)
  • Easy tag creation (log.setTag())
  • Enable/Disable Levels (log.getSettings().setLevels(Level.ERROR))
  • Current Method Logging (log.d())

Usage and Samples:

1- Simple

 public static class MyView {
    ILog log = new ILog();
    public void doSomeStuff() {
      log.d("doing some stuff");
      //... doing stuff
     }
  }

Result:
2014-06-20 02:53:54   -Debug     MyView   doing some stuff

Notice that didn’t set the tag value, so ILog got the tag from current Class name (MyView).


2- Smart

public static class Utility {
  ILog log = new ILog();
  public void calculateMiles() {
    log.d();
    //...calculating
  }
}

Result:
2014-06-20 03:13:29   -Debug     Utility   [51:com.sample.Utility] calculateMiles()

The result did print the current method (claculateMiles()) and the line number (51) also the class path (com.sample.Utility)


3- Controls

public static class UserProfile {
   ILog log = new ILog();
   public UserProfile() {
    log.getSettings().setLevels(Level.ERROR);
    }
   public void creatNewUser() {
    log.d("creating new user");
    //...something went wrong
    log.e("couldn't create user profile");
   }
}

Result:
2014-06-20 03:24:15   -Error     UserProfile   couldn't create user profile


4- File Logging

public static class GpsTracker {
   ILog log = new ILog();
   public GpsTracker() {
      HtmlFileLogger htmlLogger = new HtmlFileLogger();
      htmlLogger.createLogFile("/users/logging_directory/");
      log.setFileLogger(htmlLogger);
    }
  public void onPositionChanged(long lng, long lat) {
    log.d("longitude " + lng + " ,latitude " + lat);
    }
}

Result:
2014-06-20 03:38:45 -Debug GpsTracker longitude 110000023 ,latitude 1232444444
2014-06-20 03:38:45 -Debug GpsTracker longitude 110000444 ,latitude 1232444443
2014-06-20 03:38:45 -Debug GpsTracker longitude 110000554 ,latitude 1232444442

log file name:
ILog_2014_06_20__03_38_45_709.html

Snapshot of the html logging file
Screen Shot 2014-06-20 at 3.38.52 AM

Get the library on Github here https://github.com/MoshDev/ILog

Leave a Reply

Your email address will not be published. Required fields are marked *