Minor: add more logging in KotlinBuilder

This commit is contained in:
Zalim Bashorov
2015-11-26 17:32:12 +03:00
parent 5f13dc31f1
commit 7faa886d26
2 changed files with 15 additions and 1 deletions
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.INFO
import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil
import org.jetbrains.kotlin.config.CompilerSettings import org.jetbrains.kotlin.config.CompilerSettings
import org.jetbrains.kotlin.jps.build.KotlinBuilder
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
import org.jetbrains.kotlin.progress.CompilationCanceledStatus import org.jetbrains.kotlin.progress.CompilationCanceledStatus
import org.jetbrains.kotlin.rmi.* import org.jetbrains.kotlin.rmi.*
@@ -108,6 +109,7 @@ public object KotlinCompilerRunner {
if (!tryCompileWithDaemon(compilerClassName, argsArray, environment, messageCollector, collector)) { if (!tryCompileWithDaemon(compilerClassName, argsArray, environment, messageCollector, collector)) {
// otherwise fallback to in-process // otherwise fallback to in-process
KotlinBuilder.LOG.info("Compile in-process")
val stream = ByteArrayOutputStream() val stream = ByteArrayOutputStream()
val out = PrintStream(stream) val out = PrintStream(stream)
@@ -176,9 +178,12 @@ public object KotlinCompilerRunner {
if (isDaemonEnabled()) { if (isDaemonEnabled()) {
KotlinBuilder.LOG.debug("Try to connect to daemon")
val connection = getDaemonConnection(environment, messageCollector) val connection = getDaemonConnection(environment, messageCollector)
if (connection?.daemon != null) { if (connection?.daemon != null) {
KotlinBuilder.LOG.info("Connected to daemon")
val compilerOut = ByteArrayOutputStream() val compilerOut = ByteArrayOutputStream()
val daemonOut = ByteArrayOutputStream() val daemonOut = ByteArrayOutputStream()
@@ -199,6 +204,8 @@ public object KotlinCompilerRunner {
} }
return true return true
} }
KotlinBuilder.LOG.info("Daemon not found")
} }
return false return false
} }
@@ -65,6 +65,7 @@ import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.progress.CompilationCanceledException import org.jetbrains.kotlin.progress.CompilationCanceledException
import org.jetbrains.kotlin.progress.CompilationCanceledStatus import org.jetbrains.kotlin.progress.CompilationCanceledStatus
import org.jetbrains.kotlin.resolve.jvm.JvmClassName import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.rmi.isDaemonEnabled
import org.jetbrains.kotlin.utils.LibraryUtils import org.jetbrains.kotlin.utils.LibraryUtils
import org.jetbrains.kotlin.utils.PathUtil import org.jetbrains.kotlin.utils.PathUtil
import org.jetbrains.kotlin.utils.keysToMap import org.jetbrains.kotlin.utils.keysToMap
@@ -91,6 +92,7 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
LOG.debug("==========================================") LOG.debug("==========================================")
LOG.info("is Kotlin incremental compilation enabled: ${IncrementalCompilation.isEnabled()}") LOG.info("is Kotlin incremental compilation enabled: ${IncrementalCompilation.isEnabled()}")
LOG.info("is Kotlin experimental incremental compilation enabled: ${IncrementalCompilation.isExperimental()}") LOG.info("is Kotlin experimental incremental compilation enabled: ${IncrementalCompilation.isExperimental()}")
LOG.info("is Kotlin compiler daemon enabled: ${isDaemonEnabled()}")
val historyLabel = context.getBuilderParameter("history label") val historyLabel = context.getBuilderParameter("history label")
if (historyLabel != null) { if (historyLabel != null) {
@@ -108,12 +110,17 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
val messageCollector = MessageCollectorAdapter(context) val messageCollector = MessageCollectorAdapter(context)
try { try {
return doBuild(chunk, context, dirtyFilesHolder, messageCollector, outputConsumer) val result = doBuild(chunk, context, dirtyFilesHolder, messageCollector, outputConsumer)
LOG.debug("Build result: " + result)
return result
} }
catch (e: StopBuildException) { catch (e: StopBuildException) {
LOG.debug("Caught exception: " + e)
throw e throw e
} }
catch (e: Throwable) { catch (e: Throwable) {
LOG.debug("Caught exception: " + e)
messageCollector.report( messageCollector.report(
CompilerMessageSeverity.EXCEPTION, CompilerMessageSeverity.EXCEPTION,
OutputMessageUtil.renderException(e), OutputMessageUtil.renderException(e),