How do you usually Tag log entries? (android)

后端 未结 13 1577
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 21:54

I assume most of you are aware of android.util.Log All logging methods accept \'String tag\' as a first argument.

And my question is How do you usually tag y

13条回答
  •  旧巷少年郎
    2020-12-22 22:08

    they use Timber for the IOsched app 2019 to show debug info:

    implementation 'com.jakewharton.timber:timber:4.7.1'

    class ApplicationController: Application() {
    
    override fun onCreate() {  
        super.onCreate()
        if(BuildConfig.DEBUG){
            Timber.plant(Timber.DebugTree())
        }
    }   
    // enables logs for every activity and service of the application
    // needs to be registered in manifest like:  
     
    

    usage

      Timber.e("Error Message") 
      // will print ->  D/MainActivity: Error Message
    
      Timber.d("Debug Message");
      Timber.tag("new tag").e("error message");
    

    note that this makes the Logs available only during DEBUG state and facilitates you the task of removing them manually for the launch on Google Play -

    when release the app on the play store, we need to remove all Log statement from the app, so that none of the application data such as user information, hidden application data, auth-tokens are available to user in logcat as plain text

    check out this article https://medium.com/mindorks/better-logging-in-android-using-timber-72e40cc2293d

提交回复
热议问题