Easy logging on Android with Kotlin context receivers


Plank is an Android library for easy logging using context receivers.




There are 3 flavours to choose from:

  1. Seal:
"Logging using the «seal» flavour" log debug
  1. Func:
log("Logging using the «func» flavour")
  1. Classic:
Plank.d("Logging using the «classic» flavour")

All of the above yield the same results and the tag is inferred based on the class from which the message is logged. In this case, the only difference is syntax.


  1. Choose one flavour:
    • Seal
    • Func
    • Classic
  2. Add kotlin compiler options:
// module-level build.gradle.kts
kotlinOptions {
    // ...
    freeCompilerArgs = listOf("-Xcontext-receivers")


Apart from logging, the library supports muting the messages. All of the below can only be called from the Application class.

  1. Seal:
Plank.muteAll() // prevents any logging
verbose.mute() // mutes all verbose type messages
  1. Func:
PlankConfig.mute() // the same as muteAll() from seal
  1. Classic:
Plank.mute() // the same as mute() from func or muteAll() from seal

Additional parameters

  • tag – functions from the func and seal flavours can receive a parameter tag, in case you want messages from different classes to have the same name or just want a custom tag.
  • type – log() from the func flavour also accepts this optional parameter denoting whether it is a debug, info, warn or some other type of message. Defaults to debug.


Due to the Any context receiver of these functions, they cannot be used inside top-level functions.


Any feedback is welcome!


View Github

Leave a Reply

Your email address will not be published. Required fields are marked *