A small, extensible logger library for Android.
Requirement: Kotlin 1.4 or higher
-
Add the dependency in your app/build.gradle:
implementation "co.novemberfive.skidder:skidder:$version"
TODO: add Maven repository
-
add service(s) to Skidder
if (BuildConfig.DEBUG) { Skidder.addService(LogcatLoggingService(id = "logcat", level = LogLevel.DEBUG)) }
-
set global variables (optional)
Skidder.apply { environment = "UAT" setGlobal("global variable", "Testy McTestface") }
-
start logging
Skidder.log(LogLevel.DEBUG, TAG, message = "Button was pressed.") logDebug(TAG, name = "button-click", message = "Button was pressed.") //shorthand method Skidder.logException(TAG, RuntimeException("Oh ow, something went wrong!")) logException(TAG, RuntimeException("It broke, again...")) //optionally, add extra data Skidder.log(LogLevel.DEBUG, TAG, name = "button-click", message = "Button was pressed.", data = mapOf("id" to "555", "info" to "blablabla"))
The core library contains one predefined service: the LogcatLoggingService
, which uses Android's Log
class, but you can write your own services by extending ILoggingService
.
The output of the LogcatLoggingService
will look like this:
co.novemberfive.android.skidder.sample D/MainActivity: button-click - Button Debug was pressed.
{
"timeStamp": 1624364291505,
"level": "DEBUG",
"tag": "MainActivity",
"name": "button-click",
"message": "Button was pressed.",
"environment": "UAT",
"data": {
"id": "555",
"info": "blablabla"
},
"globalVariables": {
"global variable": "test test test"
}
}
implementation "co.novemberfive.skidder:crashlytics:$version"
TODO: further explain how to use the CrashlyticsLoggingService