Skip to content
/ klog Public

Logging facade and basic implementations for Kotlin multi-platform.

License

Notifications You must be signed in to change notification settings

danbrough/klog

Repository files navigation

Kotlin multiplatform logging facade

Light-weight logging facade for kotlin multi-platform.

Implementations default to simple stdout loggers on native targets, SLFJ on jvm and the Android Log on android.

Alternatively kotlin-logging is available as well or you can trivially wire it up to anything with a similar api.

Initial demo builds are available via maven at:

repositories {
  maven("https://maven.danbrough.org")
}

dependencies {
  implementation("org.danbrough.klog:core:0.0.3-beta01")
}

The core KMP library has the api and basic stdout loggers which are the default implementations, apart from android which delegates to the android logger. If you would like to delegate to kotlin-logging then add the implementation("org.danbrough.klog:oshahi:..") KMP library to commonMain and initialise your application with klog.kloggingOshai{}.

To delegate to SLFJ use implementation("org.danbrough.klog:slf4j:..") in you jvm or android application. Initialise it with klog.kloggingSlf4j{} and configure your slf4j implementation as per usual.

package stuff

import klog.logging

class Foo {
  private val log by logger() //logger with name "stuff.Foo"
  //alternatively:
  //private val log = klog.logger("stuff.Foo")

  fun test() {
    log.trace { "A trace call" } //or debug,info,warn,error ..
    log.error(Exception("An exception")) { "An error occurred" }
  }
}

About

Logging facade and basic implementations for Kotlin multi-platform.

Resources

License

Stars

Watchers

Forks

Packages

No packages published