31 May 2013

How to DO NOT logging in Android based on my fail :)

As my android's application is quite simple,so they don't log too much.I use mainly 3 types of logs
Error, if program done something,which not suppose to happen
Warning ,if things user done something wrong
Info  - various useful information about  tricky methods and  features  and their progress or result.

 I used Log.wtf() to check progress of result of features which i currently working on.However.For lazyness and being in rush reason I left them without changing to right priority  ...
That was a mistakes as few days after i start seeing spontaneous  crash reports:

"android.util.Log$TerribleFailure in android.util.Log.wtf"

So I think ... WTF? What I terrible failure i made to see that.
Well... documentation explains that :
"  Depending on system configuration, a report may be added to the DropBoxManager and/or the process may be terminated immediately with an error dialog. " http://developer.android.com/reference/android/util/Log.html
This clearly explains why left wtf logs was a bad idea.Well.
It means 2 doms learn chinese and doms quiz game will require an update soon.

Remember kids!:  Clumsiness cause problems!

NOTE! It worth to add that Log.wtf() was  added in API level 8 (so it works since Froyo!),so if you planning make your app compatible with Android 2.1 or earier, then ... do not use wtf() as it generate Exception too.

Tip: A good convention is to declare a TAG constant in your class:
private static final String TAG = "AnActivity";
( As documentation states and i  found this tip useful too ,so I add this here.) 

Resources:
http://developer.android.com/reference/android/util/Log.html