Simple multiplatform logging in Kotlin
Go to file
2022-06-09 09:56:27 +06:00
.github/workflows Update kdocs.yml 2022-06-07 23:15:58 +06:00
gradle fixes 2022-06-07 22:22:28 +06:00
src start implement lazy messages api 2022-06-09 09:56:27 +06:00
.gitignore Initial commit 2022-06-07 13:17:21 +04:00
build.gradle dokka.gradle 2022-06-07 23:14:01 +06:00
changelog_parser.sh add publication workaround 2022-06-07 20:30:54 +06:00
CHANGELOG.md start 0.2.1 2022-06-09 09:41:41 +06:00
defaultAndroidSettings.gradle Initial commit 2022-06-07 13:17:21 +04:00
dokka.gradle dokka.gradle 2022-06-07 23:14:01 +06:00
github_release.gradle add publication workaround 2022-06-07 20:30:54 +06:00
gradle.properties start 0.2.1 2022-06-09 09:41:41 +06:00
gradlew Initial commit 2022-06-07 13:17:21 +04:00
gradlew.bat Initial commit 2022-06-07 13:17:21 +04:00
LICENSE Initial commit 2022-06-07 13:17:21 +04:00
publish.gradle add publication workaround 2022-06-07 20:30:54 +06:00
publish.kpsb add publication workaround 2022-06-07 20:30:54 +06:00
README.md Update README.md 2022-06-09 02:41:13 +06:00
settings.gradle perestroika 2022-06-07 20:02:59 +06:00

How to use

JVM Android Js

KDocs Tutorials

It is simple logging tool which is using built-in tools for logging:

  • java.util.logging.Logger for JVM
  • android.util.Log for Android
  • Console for JS

How to use

Fast-travel

Just use some boring extensions like:

KSLog.i("Some message")
// OR
KSLog.i("Some tag", "Some message")
// OR
KSLog.i("Some tag", "Some message", IllegalArgumentException("So, that is exception :)"))
// OR EVEN
KSLog.l(LogLevel.INFO, "Some tag", "Some message", IllegalArgumentException("So, that is exception :)"))

A little bit deeper

There are several important things in context of this library:

  • Default logger (available via KSLog)
  • Local logger (can be created via KSLog functions and passed anywhere as KSLog)
  • Logging shortcuts like KSLog.i/KSLog.info

Default logger can be created by passing defaultTag and one of variants log level filters: set or minimal loggable level. In JVM you also may setup any logger as base logger for default realizations of KSLog. Besides, you may use your own callback (on any target platform) as output of logging:

val logger = KSLog { logLevel, optionalTag, message, optionalThrowable ->
    println("[$logLevel] $optionalTag - $message: $optionalThrowable.stackTraceToString()")
}

In the example above we will take the logger which will just print incoming data as common output.

Installation

Maven Central

Gradle

implementation "dev.inmo:kslog:$kslog_version"

Maven

<dependency>
  <groupId>dev.inmo</groupId>
  <artifactId>kslog</artifactId>
  <version>${kslog_version}</version>
</dependency>