[Wasm] Print result of webpack and webpack process not into error log level, print everything from webpack to info log
^KT-64601 fixed
This commit is contained in:
+4
-4
@@ -13,7 +13,7 @@ import org.gradle.internal.logging.progress.ProgressLogger
|
||||
import org.jetbrains.kotlin.gradle.utils.clearAnsiColor
|
||||
import java.text.ParseException
|
||||
|
||||
class TeamCityMessageCommonClient(
|
||||
open class TeamCityMessageCommonClient(
|
||||
internal val clientType: LogType,
|
||||
internal val log: Logger
|
||||
) : ServiceMessageParserCallback {
|
||||
@@ -52,7 +52,7 @@ class TeamCityMessageCommonClient(
|
||||
null
|
||||
}
|
||||
|
||||
private fun printMessage(text: String, type: LogType?) {
|
||||
internal open fun printMessage(text: String, type: LogType?) {
|
||||
val value = text.trimEnd()
|
||||
progressLogger?.progress(value)
|
||||
|
||||
@@ -78,10 +78,10 @@ class TeamCityMessageCommonClient(
|
||||
}
|
||||
|
||||
override fun regularText(text: String) {
|
||||
if (clientType == LogType.ERROR || clientType == LogType.WARN) {
|
||||
if (clientType.isErrorLike()) {
|
||||
printMessage(text, clientType)
|
||||
} else {
|
||||
printMessage(text, LogType.DEBUG)
|
||||
printMessage(text, LogType.INFO)
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -18,6 +18,7 @@ internal fun SlfLogger.processLogMessage(
|
||||
type = type,
|
||||
error = ::error,
|
||||
warn = ::warn,
|
||||
lifecycle = ::info,
|
||||
info = ::info,
|
||||
debug = ::debug
|
||||
)
|
||||
@@ -33,6 +34,7 @@ internal fun GradleLogger.processLogMessage(
|
||||
type = type,
|
||||
error = ::error,
|
||||
warn = ::warn,
|
||||
lifecycle = ::lifecycle,
|
||||
info = ::info,
|
||||
debug = ::debug
|
||||
)
|
||||
@@ -43,6 +45,7 @@ private fun processLogMessageInternal(
|
||||
type: LogType,
|
||||
error: (text: String) -> Unit,
|
||||
warn: (text: String) -> Unit,
|
||||
lifecycle: (text: String) -> Unit,
|
||||
info: (text: String) -> Unit,
|
||||
debug: (text: String) -> Unit
|
||||
) {
|
||||
@@ -54,6 +57,7 @@ private fun processLogMessageInternal(
|
||||
LogType.ERROR -> {
|
||||
error(nonColoredMessage)
|
||||
}
|
||||
LogType.LIFECYCLE -> lifecycle(nonColoredMessage)
|
||||
LogType.INFO, LogType.LOG -> info(nonColoredMessage)
|
||||
LogType.DEBUG -> debug(nonColoredMessage)
|
||||
}
|
||||
@@ -62,6 +66,7 @@ private fun processLogMessageInternal(
|
||||
enum class LogType(val value: String) {
|
||||
ERROR("error"),
|
||||
WARN("warn"),
|
||||
LIFECYCLE("lifecycle"),
|
||||
INFO("info"),
|
||||
DEBUG("debug"),
|
||||
LOG("log");
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import java.io.OutputStream
|
||||
* Calls [client] for each parsed message and regular text.
|
||||
*
|
||||
* TeamCity server messages should ends with new line.
|
||||
* Only messages short than [MESSAGE_LIMIT_BYTES] supported.
|
||||
* Only messages shorter than [MESSAGE_LIMIT_BYTES] supported.
|
||||
*/
|
||||
internal class TCServiceMessageOutputStreamHandler(
|
||||
private val client: ServiceMessageParserCallback,
|
||||
|
||||
-29
@@ -150,7 +150,6 @@ data class KotlinWebpackConfig(
|
||||
appendSourceMaps()
|
||||
appendOptimization()
|
||||
appendDevServer()
|
||||
appendProgressReporter()
|
||||
rules.forEach { rule ->
|
||||
if (rule.active) {
|
||||
with(rule) { appendToWebpackConfig() }
|
||||
@@ -313,34 +312,6 @@ data class KotlinWebpackConfig(
|
||||
)
|
||||
}
|
||||
|
||||
private fun Appendable.appendProgressReporter() {
|
||||
if (!progressReporter) return
|
||||
|
||||
//language=ES6
|
||||
appendLine(
|
||||
"""
|
||||
// Report progress to console
|
||||
// noinspection JSUnnecessarySemicolon
|
||||
;(function(config) {
|
||||
const webpack = require('webpack');
|
||||
const handler = (percentage, message, ...args) => {
|
||||
const p = percentage * 100;
|
||||
let msg = `${"$"}{Math.trunc(p / 10)}${"$"}{Math.trunc(p % 10)}% ${"$"}{message} ${"$"}{args.join(' ')}`;
|
||||
${
|
||||
if (progressReporterPathFilterInput == null) "" else """
|
||||
msg = msg.replace(require('path').resolve(__dirname, ${progressReporterPathFilterInput!!.jsQuoted()}), '');
|
||||
""".trimIndent()
|
||||
};
|
||||
console.log(msg);
|
||||
};
|
||||
|
||||
config.plugins.push(new webpack.ProgressPlugin(handler))
|
||||
})(config);
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
private fun json(obj: Any) = StringWriter().also {
|
||||
GsonBuilder().setPrettyPrinting().create().toJson(obj, it)
|
||||
}.toString()
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ internal data class KotlinWebpackRunner(
|
||||
clientType: LogType,
|
||||
progressLogger: ProgressLogger?
|
||||
): TeamCityMessageCommonClient {
|
||||
return TeamCityMessageCommonClient(clientType, logger)
|
||||
return WebpackLogClient(clientType, logger)
|
||||
.apply {
|
||||
if (progressLogger != null) {
|
||||
this.progressLogger = progressLogger
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import org.gradle.api.logging.Logger
|
||||
import org.jetbrains.kotlin.gradle.internal.LogType
|
||||
import org.jetbrains.kotlin.gradle.internal.TeamCityMessageCommonClient
|
||||
|
||||
class WebpackLogClient(
|
||||
clientType: LogType,
|
||||
log: Logger
|
||||
) : TeamCityMessageCommonClient(clientType, log) {
|
||||
override fun regularText(text: String) {
|
||||
if (WEBPACK_INITIAL_REGEX.matches(text)) {
|
||||
printMessage(text, LogType.LIFECYCLE)
|
||||
} else {
|
||||
super.regularText(text)
|
||||
}
|
||||
}
|
||||
|
||||
override fun printMessage(text: String, type: LogType?) {
|
||||
if (WEBPACK_COMPILED_REGEX.matches(text)) {
|
||||
super.printMessage(text, LogType.LIFECYCLE)
|
||||
} else {
|
||||
super.printMessage(text, type)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal val WEBPACK_COMPILED_REGEX = "webpack (.+) compiled (.+) in .+\\s".toRegex()
|
||||
internal val WEBPACK_INITIAL_REGEX = "<i> \\[.+] .+\\s".toRegex()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user