Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Logging in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 186
    Comment on it

    A very nice system is use for logging in android, usually called a centralized system.
    Developer can filter log statements by using android tools.

    We can create log statements by using android.util.Log class. Log class have so many methods like Log.v(),Log.e(), Log.d(), Log.w() , Log.i() or Log.wtf()
    They all have two parameters : One is the category of the log and other is the message.

    Typically we create an Interface having your log category.

    public interface MyConstants {
    String LOG_TAG = com.package.myapplication;
    }
    

    To show log we use it like this.
    if(BuildConfig.DEBUG){
    Log.e(MyConstants.LOG_TAG, Its a log. Got it successfully....);
    }
    

    We make a condition of BuildConfig because the deployed app should not contain any logs to show. Android provide BuildConfig.DEBUG for this purpose. BuildConfig.DEBUG returns false if we export our app for deployement.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: