A very lite weight Log library for Android.
Very easy to migrate from android Log to AndroidEasyLog.
Easily enable/disable logs in your app without changing much in your current codes.
It also shows code line number in the log.
Very convenient for tracing problems.
01-27 12:18:35.086 15686-15686/com.sotwtm.log.sample D/Log: <15686>[(MainActivity.kt:96)#onClickLog] Clicked at : Fri Jan 27 12:18:35 GMT+08:00 2017
implementation 'com.sotwtm.util:ec-log:1.0.0'
// Show all logs
Log.logLevel = Log.VERBOSE
// Hide all logs
Log.logLevel = Log.NONE
Set the following in your application class onCreate method before any log.
//...
import com.sotwtm.util.Log
class M88Application : Application() {
override fun onCreate() {
//...
Log.logLevel = if (BuildConfig.DEBUG) Log.VERBOSE else Log.NONE
//...
}
//...
}
Simply replace with the following
import android.util.Log
with
import com.sotwtm.util.Log
We have all log methods taking one parameter (the log) only.
This can ease your pain on logging things.
To let multiple log TAG available, the android.util.Log 's two parameters methods is still there.
Log.defaultLogTag = "MyLogTag"
// Then, the following will be equivalent
Log.d("This is log")
android.util.Log("MyLogTag", "This is log")
// This is the aciton will be taken on release build
Log.actionOnWtf = object : Log.OnWtfListener { }
// This is the action will be taken on debug build
Log.actionOnWtfDebug = object : Log.OnWtfListener { }
Disable log does not mean the log method won't be called.
So, for some logs that could take time. It is still recommended to skip the call to log.
if (Log.isDebuggable) {
// Do only if the app is debuggable (loggable)
}
OR by removing them by prograud
-assumenosideeffects class com.sotwtm.util.Log {
public static *** v(...);
public static *** d(...);
public static *** i(...);
public static *** w(...);
public static *** e(...);
public static *** wtf(...);
}