Forward stdout and stderr logger of out of process compiler through gradle logging
Issue #KT-30596 Fixed
This commit is contained in:
committed by
Alexey Tsvetkov
parent
d86ffd3f34
commit
6bef27e1e8
@@ -10,6 +10,5 @@ interface KotlinLogger {
|
||||
fun warn(msg: String)
|
||||
fun info(msg: String)
|
||||
fun debug(msg: String)
|
||||
|
||||
val isDebugEnabled: Boolean
|
||||
}
|
||||
+12
-3
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.daemon.client.DaemonReportingTargets
|
||||
import org.jetbrains.kotlin.daemon.client.launchProcessWithFallback
|
||||
import org.jetbrains.kotlin.gradle.logging.GradleKotlinLogger
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor
|
||||
import org.jetbrains.org.objectweb.asm.FieldVisitor
|
||||
@@ -82,12 +83,20 @@ internal fun runToolInSeparateProcess(
|
||||
// important to read inputStream, otherwise the process may hang on some systems
|
||||
val readErrThread = thread {
|
||||
process.errorStream!!.bufferedReader().forEachLine {
|
||||
System.err.println(it)
|
||||
logger.error(it)
|
||||
}
|
||||
}
|
||||
process.inputStream!!.bufferedReader().forEachLine {
|
||||
System.out.println(it)
|
||||
|
||||
if (logger is GradleKotlinLogger) {
|
||||
process.inputStream!!.bufferedReader().forEachLine {
|
||||
logger.lifecycle(it)
|
||||
}
|
||||
} else {
|
||||
process.inputStream!!.bufferedReader().forEachLine {
|
||||
System.out.println(it)
|
||||
}
|
||||
}
|
||||
|
||||
readErrThread.join()
|
||||
|
||||
val exitCode = process.waitFor()
|
||||
|
||||
+4
@@ -25,6 +25,10 @@ internal class GradleKotlinLogger(private val log: Logger) : KotlinLogger {
|
||||
log.warn(msg)
|
||||
}
|
||||
|
||||
fun lifecycle(msg: String) {
|
||||
log.lifecycle(msg)
|
||||
}
|
||||
|
||||
override val isDebugEnabled: Boolean
|
||||
get() = log.isDebugEnabled
|
||||
}
|
||||
Reference in New Issue
Block a user