Put KotlinLogging Logger call in another file and retain name
I want to do something like
// In Log.kt
val logger = KotlinLogging.logger {}
// In Main.kt after importing logger
fun main() {
val loggerMain = KotlinLogging.logger {}
loggerMain.info("Hello world") // Main: Hello world
// I want logger to have the same name as loggerMain instead.
logger.info("Hello world") // Log: Hello world
}
I want to reduce the amount of unnecessary boiler plate if possible, and having to create a variable containing the logger for every scope that needs it is something I want to avoid.
I.e. inside of Log.kt, I want to give the logger the name of whatever file accessed it as if it were declared 开发者_运维问答in that file.
精彩评论