Skip to main content


Dependency installation

Maven Central

Gradle (Groovy)

implementation "dev.inmo:kslog:$kslog_version"

Gradle (Kotlin Script)


Maven (pom)


Setup in code

The main point in setup in your code is to setup default logger:

KSLog.default = KSLog("defaultTag")

You may use custom messageFormatter in any of KSLog factory to customize output of KSLog logging. For example:

  messageFormatter = { level, tag, message, throwable ->
    println("[$level] $tag - $message: $throwable")

Additionally you may use one of several different settings:

  • filter - callback which will be triggered before any real logging. When filter returns true the incoming data will be logged
  • minLoggingLevel - minimal logging level for the log which will be logged. The order of log level is next:
    • DEBUG
    • INFO
    • ERROR
    • ASSERT
  • levels - and iterable with the levels which should be logged
  • firstLevel,secondLevel,otherLevels - as levels, but vararg :)

In case you are passing minLoggingLevel, the level and more important levels will be passed to logs. For example, when you are settings up your logger as in next snippet:

val logger = KSLog(
    minLoggingLevel = LogLevel.INFO

The next levels will be logged with logger:

  • INFO

Special loggers


It is logger which will call incoming performLogCallback on each logging. This logger can be create simply with one callback:

KSLog { level, tag, message, throwable ->
  println("[$level] $tag - $message: $throwable")


It is simple value class which can be used for zero-cost usage of some tag and calling for KSLog.default. For example, if you will create tag logger with next code:

val logger = TagLogger("tagLoggerTag")

The logger will call KSLog.default with the tag tagLoggerTag on each calling of logging.

Automatical loggers

There are two things which can be useful in your code: logger and logTag extensions. logTag is the autocalculated by your object classname tag. logger extension can be used with applying to any object like in the next snippet:

class SomeClass {
  init {

The code above will trigger calling of logging in KSLog.default with level LogLevel.INFO using tag SomeClass and message "inited". As you could have guessed, logger is using TagLogger with logTag underhood and the most expensive operation here is automatical calculation of logTag.

  • Extension logger

JVM specific setup

For JVM you may setup additionally use java loggers as the second parameter of KSLog factory. For example: