Skip to content

Latest commit

 

History

History
82 lines (64 loc) · 2.53 KB

README.md

File metadata and controls

82 lines (64 loc) · 2.53 KB

App Logger for Android

Platform Version Support Kotlin version badge

App Logger that allows app logs visualization, classification, filtering, sharing and recording from the application where it is included.

Installation

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'
    ...
}

Configuration

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))

Demo app

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.

Contributing

See CONTRIBUTING.md