[Wasm]Log webpack result only in there was infrastructure logging before
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.targets.js.webpack
|
||||||
|
|
||||||
|
class InfrastructureLogged(
|
||||||
|
var value: Boolean
|
||||||
|
)
|
||||||
+7
-4
@@ -48,9 +48,10 @@ internal data class KotlinWebpackRunner(
|
|||||||
|
|
||||||
private fun configureClient(
|
private fun configureClient(
|
||||||
clientType: LogType,
|
clientType: LogType,
|
||||||
progressLogger: ProgressLogger?
|
progressLogger: ProgressLogger?,
|
||||||
|
infrastructureLogged: InfrastructureLogged,
|
||||||
): TeamCityMessageCommonClient {
|
): TeamCityMessageCommonClient {
|
||||||
return WebpackLogClient(clientType, logger)
|
return WebpackLogClient(clientType, logger, infrastructureLogged)
|
||||||
.apply {
|
.apply {
|
||||||
if (progressLogger != null) {
|
if (progressLogger != null) {
|
||||||
this.progressLogger = progressLogger
|
this.progressLogger = progressLogger
|
||||||
@@ -66,14 +67,16 @@ internal data class KotlinWebpackRunner(
|
|||||||
"${this}: Entry file not existed \"${config.entry}\""
|
"${this}: Entry file not existed \"${config.entry}\""
|
||||||
}
|
}
|
||||||
|
|
||||||
val standardClient = configureClient(LogType.LOG, progressLogger)
|
val infrastructureLogged = InfrastructureLogged(false)
|
||||||
|
|
||||||
|
val standardClient = configureClient(LogType.LOG, progressLogger, infrastructureLogged)
|
||||||
execFactory.standardOutput = TCServiceMessageOutputStreamHandler(
|
execFactory.standardOutput = TCServiceMessageOutputStreamHandler(
|
||||||
client = standardClient,
|
client = standardClient,
|
||||||
onException = { },
|
onException = { },
|
||||||
logger = standardClient.log
|
logger = standardClient.log
|
||||||
)
|
)
|
||||||
|
|
||||||
val errorClient = configureClient(LogType.ERROR, progressLogger)
|
val errorClient = configureClient(LogType.ERROR, progressLogger, infrastructureLogged)
|
||||||
execFactory.errorOutput = TCServiceMessageOutputStreamHandler(
|
execFactory.errorOutput = TCServiceMessageOutputStreamHandler(
|
||||||
client = errorClient,
|
client = errorClient,
|
||||||
onException = { },
|
onException = { },
|
||||||
|
|||||||
+6
-4
@@ -11,10 +11,12 @@ import org.jetbrains.kotlin.gradle.internal.TeamCityMessageCommonClient
|
|||||||
|
|
||||||
class WebpackLogClient(
|
class WebpackLogClient(
|
||||||
clientType: LogType,
|
clientType: LogType,
|
||||||
log: Logger
|
log: Logger,
|
||||||
|
private val infrastructureLogged: InfrastructureLogged,
|
||||||
) : TeamCityMessageCommonClient(clientType, log) {
|
) : TeamCityMessageCommonClient(clientType, log) {
|
||||||
override fun regularText(text: String) {
|
override fun regularText(text: String) {
|
||||||
if (WEBPACK_INITIAL_REGEX.matches(text)) {
|
if (WEBPACK_INFRASTRUCTURE_REGEX.matches(text)) {
|
||||||
|
infrastructureLogged.value = true
|
||||||
printMessage(text, LogType.LIFECYCLE)
|
printMessage(text, LogType.LIFECYCLE)
|
||||||
} else {
|
} else {
|
||||||
super.regularText(text)
|
super.regularText(text)
|
||||||
@@ -22,7 +24,7 @@ class WebpackLogClient(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun printMessage(text: String, type: LogType?) {
|
override fun printMessage(text: String, type: LogType?) {
|
||||||
if (WEBPACK_COMPILED_REGEX.matches(text)) {
|
if (infrastructureLogged.value && WEBPACK_COMPILED_REGEX.matches(text)) {
|
||||||
super.printMessage(text, LogType.LIFECYCLE)
|
super.printMessage(text, LogType.LIFECYCLE)
|
||||||
} else {
|
} else {
|
||||||
super.printMessage(text, type)
|
super.printMessage(text, type)
|
||||||
@@ -31,6 +33,6 @@ class WebpackLogClient(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal val WEBPACK_COMPILED_REGEX = "webpack (.+) compiled (.+) in .+\\s".toRegex()
|
internal val WEBPACK_COMPILED_REGEX = "webpack (.+) compiled (.+) in .+\\s".toRegex()
|
||||||
internal val WEBPACK_INITIAL_REGEX = "<i> \\[.+] .+\\s".toRegex()
|
internal val WEBPACK_INFRASTRUCTURE_REGEX = "<i> \\[.+] .+\\s".toRegex()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user