In Kotlin KSP, I try to debug the processor
internal class ListedProcessor(
    private val fileGenerator: FileWriter,
) : SymbolProcessor {
    override fun process(resolver: Resolver): List<KSAnnotated> {
        val listedFunctions: Sequence<KSFunctionDeclaration> =
            resolver.findAnnotations(Listed::class)
        val arrayedFunctions: Sequence<KSFunctionDeclaration> =
            resolver.findAnnotations(Arrayed::class)
        return (listedFunctions + arrayedFunctions).filterNot { it.validate() }.toList()
    }
}
I try to use println but don't know where the output goes to. How can I dump out log for Kotlin KSP?
As per the conversation in Kotlin Slack, please use the KSPLogger to perform logging. For example:
logger.warn(allFiles.toList().toString())
You can get a handle on the KSPLogger through the environment parameter in the create function of your SymbolProcessorProvider:
class TestProcessorProvider : SymbolProcessorProvider {
    override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
        return TestProcessor(environment.codeGenerator, environment.logger)
    }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With