Wednesday, May 13, 2015

MyNotes : Logging Made Easier

Before I proceed much further I want to bring in a logging framework.  I am going to use Hugo.  It provides everything I want for the trace logging and it does it with a single annotation which is very nice.  I included my steps to incorporate below, but I really just followed the setup instructions provided on the website.

MyNotesProject build.gradle file:


dependencies {
...
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}

And then I add the following line into the MyNotes and Common Library module build.gradle file:


apply plugin: 'com.jakewharton.hugo'

To trace log a method I just have to add the following annotation to the method: @DebugLog.


Example


If I add the annotation to the MainActivity onCreate method:



@Override
@DebugLog
public Loader<List<Note>> onCreateLoader(final int id, final Bundle args) {
return new FilteredNoteLoader(this);
}

Then I automatically get the following log entry in my logcat:


com.fsk.mynotes I/art﹕ Not late-enabling -Xcheck:jni (already on)
com.fsk.mynotes V/MainActivity﹕ ⇢ onCreateLoader(id=0, args=null)
com.fsk.mynotes V/MainActivity﹕ ⇠ onCreateLoader [364ms] = FilteredNoteLoader{389f6776 id=0}

com.fsk.mynotes D/OpenGLRenderer﹕ Render dirty regions requested: true


Commits


The commits for these changes can be found here.

No comments :

Post a Comment