App Logger that allows app logs visualization, classification, filtering, sharing and recording from the application where it is included.
Inside the dependency block in the build.gradle
of your application, add this line to add the library:
dependencies {
...
implementation 'com.telefonica:androidlogger:$version'
...
}
In case you want to disable any logging on release versions (and avoid inclusion of any transitive libraries), we provide a no-op version that will do nothing, without the need of handling this from your app code:
dependencies {
...
debugImplementation 'com.telefonica:androidlogger:$version'
releaseImplementation 'com.telefonica:androidlogger-no-op:$version'
...
}
To initialize the logger, call initAppLogger
in your Application's onCreate:
open class MyApplication : Application() {
val categories: List<LogCategory> = listOf(
LogCategory(
name = "UI",
color = Color.parseColor("#28A745"),
logTags = listOf(
"MyActivity",
"MyFragment",
)
),
LogCategory(
name = "Your Category",
color = Color.parseColor("#17A2B8"),
logTags = listOf(
"MyStorage",
"MyApiClient",
)
),
)
override fun onCreate() {
super.onCreate()
initAppLogger(applicationContext, LoggerGroup.values().flatMap(transformation))
}
}
And use log
to write a log entry:
log(DEBUG, "MyActivity", "onCreate happened")
Finally, to open the logger activity, just get the intent calling getLaunchIntent
startActivity(getLaunchIntent(context))
There is a demo app of the logger viewer window in this repository. To compile the app manually run the App module in Android Studio.
See CONTRIBUTING.md