[Daemon] Improve some daemon log messages

A few messages were improved:
  * If the daemon process died at the startup, add its last 10 lines of the output to the log and report to the EXCEPTION (ERROR in the case of Gradle) level
  * If some exception occurs during connection attempt, add its stacktrace and report to the EXCEPTION (ERROR in the case of Gradle) level
  * Added more DEBUG level messages
  * Some important messages are moved to the INFO level
  * Added a suggestion to report issue to kotl.in/issue
^KT-55322 Fixed
This commit is contained in:
Alexander.Likhachev
2023-11-21 12:58:05 +01:00
committed by Space Team
parent 95bc49054f
commit b000b66ef7
8 changed files with 120 additions and 27 deletions
@@ -69,10 +69,6 @@ class ExecutionStrategyJvmIT : ExecutionStrategyIT() {
}
abstract class ExecutionStrategyIT : KGPDaemonsBaseTest() {
override val defaultBuildOptions: BuildOptions = super.defaultBuildOptions.copy(
logLevel = LogLevel.DEBUG
)
@DisplayName("Compilation via Kotlin daemon")
@GradleTest
fun testDaemon(gradleVersion: GradleVersion) {
@@ -113,7 +109,9 @@ abstract class ExecutionStrategyIT : KGPDaemonsBaseTest() {
"build",
"-Pkotlin.daemon.jvmargs=-Xmxqwerty",
) {
assertOutputContains("Failed to compile with Kotlin daemon. Fallback strategy (compiling without Kotlin daemon) is turned off.")
assertOutputContains("Invalid maximum heap size: -Xmxqwerty")
assertOutputContains("Failed to compile with Kotlin daemon.")
assertOutputContains("Fallback strategy (compiling without Kotlin daemon) is turned off.")
}
}
}
@@ -146,7 +144,9 @@ abstract class ExecutionStrategyIT : KGPDaemonsBaseTest() {
"build",
"-Pkotlin.daemon.jvmargs=-Xmxqwerty",
) {
assertOutputContains("Failed to compile with Kotlin daemon. Fallback strategy (compiling without Kotlin daemon) is turned off.")
assertOutputContains("Invalid maximum heap size: -Xmxqwerty")
assertOutputContains("Failed to compile with Kotlin daemon.")
assertOutputContains("Fallback strategy (compiling without Kotlin daemon) is turned off.")
}
}
}
@@ -212,7 +212,12 @@ abstract class ExecutionStrategyIT : KGPDaemonsBaseTest() {
executionStrategy
} else {
null
}
},
logLevel = if (!testFallbackStrategy && executionStrategy == KotlinCompilerExecutionStrategy.DAEMON) {
LogLevel.DEBUG // used daemon JVM options are reported only to the DEBUG logs
} else {
defaultBuildOptions.logLevel
},
)
) {
setupProject(this)
@@ -232,6 +237,7 @@ abstract class ExecutionStrategyIT : KGPDaemonsBaseTest() {
assertNoBuildWarnings()
if (testFallbackStrategy) {
assertOutputContains("Invalid maximum heap size: -Xmxqwerty")
assertOutputContains("Using fallback strategy: Compile without Kotlin daemon")
} else if (executionStrategy == KotlinCompilerExecutionStrategy.DAEMON) {
// 256m is the default value for Gradle 5.0+
@@ -158,9 +158,12 @@ fun BuildResult.assertOutputContainsExactlyTimes(
* Assert build contains no warnings.
*/
fun BuildResult.assertNoBuildWarnings(
expectedWarnings: Set<String> = emptySet(),
additionalExpectedWarnings: Set<String> = emptySet(),
) {
val cleanedOutput = expectedWarnings.fold(output) { acc, s ->
val expectedWarnings = setOf(
"w: [InternalKotlinGradlePluginPropertiesUsed | WARNING] ATTENTION! This build uses the following Kotlin Gradle Plugin properties:"
)
val cleanedOutput = (expectedWarnings + additionalExpectedWarnings).fold(output) { acc, s ->
acc.replace(s, "")
}
val warnings = cleanedOutput
@@ -176,7 +179,6 @@ fun BuildResult.assertNoBuildWarnings(
}
val expectedK2KaptWarnings = setOf(
"w: [InternalKotlinGradlePluginPropertiesUsed | WARNING] ATTENTION! This build uses the following Kotlin Gradle Plugin properties:",
"w: Kapt currently doesn't support language version 2.0+. Falling back to 1.9."
)