WithLog

@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class WithLog(val scope: String)

Annotation for classes that will get a LOG companion extension property for logging.

The scope parameter is used to define the logging scope for the class.

Example usage:

const val MyScope = "MyScope"
@WithLog(MyScope)
class MyClass {
companion object {} // Required for the LOG extension property to be generated

fun doSomething() {
LOG.debug("Doing something")
}

class NestedClass {
fun doNestedThing() {
LOG.debug("Doing nested thing") // This will use the "MyScope" for logging
}
}

@WithLog("NestedScope")
class AnotherNestedClass {
companion object {}
fun doAnotherNestedThing() {
LOG.debug("Doing another nested thing") // This will use the "NestedScope" for logging
}
}
}

Properties

Link copied to clipboard