Provide an annotation for auto-generating an extension property for a logger
As discussed here with @rocketraman, another possibility to solve both the "auto-pollution" of any class with a logger property and the performance hit introduced by getting a cached logger instance could be to provide a KSP-based compiler plugin that auto-generates code for annotated classes.
It could work a bit similar to projects like this which auto-generate extension functions for annotated classes. A difference would be that instead of an extension function a property is generated. As the property is generated at compile-time, it can hard-code the class / logger name, avoiding the need to look up a cached logger for a specific class.
To avoid each instance of a class to get its own logger property, probably some more logic needs to be added to statically add the property to a (dummy) companion object instead.
One note: we should allow project-wide configuration with a per-annotation override to specify the logger name. Some people prefer log to logger, for example.
We should also think about how this capability/feature will integrate with:
- https://github.com/apache/logging-log4j-kotlin/issues/36
- https://github.com/apache/logging-log4j-kotlin/issues/71
I'm thinking an annotation like @BaseLogger would create a logger which is then configurable in the consuming class via DSL. But perhaps there are other approaches.