
Lightweight logging utility offering VERBOSE/INFO/WARN/DEBUG/ERROR/WTF levels, simple-to-use static-style API, overloads for tag/object/exception, robust handling of exceptions with no message and Proguard-friendly.
KmpCat is a simple Kotlin Multiplatform logging library, it supports the most common log levels (VERBOSE, INFO, WARNING, DEBUG, ERROR, WTF) and handles error prone cases such as Exceptions with no message.
It works with the following targets:
Get it via Gradle
implementation('it.xabaras.kmp.logging:kmp-cat:1.0.1')or Maven
<dependency>
<groupId>it.xabaras.kmp.logging</groupId>
<artifactId>kmp-cat</artifactId>
<version>1.0.1</version>
<type>pom</type>
</dependency>KmpCat is simple to use, you just have to call the appropriate log methods from the KmpCat object.
E.g.
KmpCat.i("Hello KmpCat! This is my first log call")
KmpCat.d("This is a debug message")
KmpCat.e("An error has occurred")
KmpCat.e("MySampleApp", exception)KmpCat provides logging methods for 6 log levels:
fun v( ... ) // VERBOSE
fun i( ... ) // INFO
fun w( ... ) // WARN
fun d( ... ) // DEBUG
fun e( ... ) // ERROR
fun wtf( ... ) // What a Terribe Failure 😃Each log level method has five overrides based on the input parameters.
Takes a message string as a parameter and logs the message Usually it gets called like this:
KmpCat.d("You just pressed the Cancel button.")Takes a tag and a message string as parameters and logs the message with the given tag Usually it gets called like this:
KmpCat.d("ExampleApp", "You just pressed the Cancel button.")Takes a tag and a Throwable (e.g. Exception) as parameters and logs the Throwable message if any
try {
// Your code
} catch(e: Exception) {
KmpCat.e("ExampleApp", e)
}Take a Kotlin object and a Throwable (e.g. Exception) as parameter, use the object's class name as a tag and logs the error message if any
try {
// Your code
} catch(e: Exception) {
KmpCat.e(this, e)
}Takes a Kotlin object and a String as parameters, uses the object's class name as a tag and logs the message
try {
// Your code
} catch(e: Exception) {
KmpCat.e(this, "We're sorry! An Exception occurred.")
}You can add the following lines to your app's proguard configuration file to enforce security (avoid adding logging methods to released app):
-assumenosideeffects class it.xabaras.kmp.logging.KmpCat {
public static void v(...)
public static void i(...)
public static void d(...)
public static void w(...)
public static void e(...)
public static void wtf(...)
}KmpCat is a simple Kotlin Multiplatform logging library, it supports the most common log levels (VERBOSE, INFO, WARNING, DEBUG, ERROR, WTF) and handles error prone cases such as Exceptions with no message.
It works with the following targets:
Get it via Gradle
implementation('it.xabaras.kmp.logging:kmp-cat:1.0.1')or Maven
<dependency>
<groupId>it.xabaras.kmp.logging</groupId>
<artifactId>kmp-cat</artifactId>
<version>1.0.1</version>
<type>pom</type>
</dependency>KmpCat is simple to use, you just have to call the appropriate log methods from the KmpCat object.
E.g.
KmpCat.i("Hello KmpCat! This is my first log call")
KmpCat.d("This is a debug message")
KmpCat.e("An error has occurred")
KmpCat.e("MySampleApp", exception)KmpCat provides logging methods for 6 log levels:
fun v( ... ) // VERBOSE
fun i( ... ) // INFO
fun w( ... ) // WARN
fun d( ... ) // DEBUG
fun e( ... ) // ERROR
fun wtf( ... ) // What a Terribe Failure 😃Each log level method has five overrides based on the input parameters.
Takes a message string as a parameter and logs the message Usually it gets called like this:
KmpCat.d("You just pressed the Cancel button.")Takes a tag and a message string as parameters and logs the message with the given tag Usually it gets called like this:
KmpCat.d("ExampleApp", "You just pressed the Cancel button.")Takes a tag and a Throwable (e.g. Exception) as parameters and logs the Throwable message if any
try {
// Your code
} catch(e: Exception) {
KmpCat.e("ExampleApp", e)
}Take a Kotlin object and a Throwable (e.g. Exception) as parameter, use the object's class name as a tag and logs the error message if any
try {
// Your code
} catch(e: Exception) {
KmpCat.e(this, e)
}Takes a Kotlin object and a String as parameters, uses the object's class name as a tag and logs the message
try {
// Your code
} catch(e: Exception) {
KmpCat.e(this, "We're sorry! An Exception occurred.")
}You can add the following lines to your app's proguard configuration file to enforce security (avoid adding logging methods to released app):
-assumenosideeffects class it.xabaras.kmp.logging.KmpCat {
public static void v(...)
public static void i(...)
public static void d(...)
public static void w(...)
public static void e(...)
public static void wtf(...)
}