I've got a logging helper function like this:
inline fun <reified T : Any> T.createChildLogger(
parentLogger: Logger,
childContext: Map<String, String> = emptyMap()
): Logger =
parentLogger.createChildLogger(getClassForLogging(T::class.java).name, childContext)
Which is used to abstract out the logic for obtaining the 'name' of the logger using the caller's class, but I'm finding I can't invoke it in-place when calling a parent constructor, like so:
class Foo(parentLogger: Logger) : Parent(createChildLogger(parentLogger))
I assume this is because the receiver function can't be applied here? Is there a workaround for something like this? (either in the definition of
createChildLogger
, or how it would be invoked by the child class?