[Gradle, JS] Move common process message logic
#KT-38109 fixed #KT-38286 fixed
This commit is contained in:
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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
|
||||
|
||||
import org.jetbrains.kotlin.gradle.utils.clearAnsiColor
|
||||
import org.gradle.api.logging.Logger as GradleLogger
|
||||
import org.slf4j.Logger as SlfLogger
|
||||
|
||||
internal fun SlfLogger.processLogMessage(
|
||||
message: String,
|
||||
type: String
|
||||
) {
|
||||
processLogMessageInternal(
|
||||
message = message,
|
||||
type = type,
|
||||
error = ::error,
|
||||
warn = ::warn,
|
||||
info = ::info,
|
||||
debug = ::debug
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
internal fun GradleLogger.processLogMessage(
|
||||
message: String,
|
||||
type: String
|
||||
) {
|
||||
processLogMessageInternal(
|
||||
message = message,
|
||||
type = type,
|
||||
error = ::error,
|
||||
warn = ::warn,
|
||||
info = ::info,
|
||||
debug = ::debug
|
||||
)
|
||||
}
|
||||
|
||||
private fun processLogMessageInternal(
|
||||
message: String,
|
||||
type: String,
|
||||
error: (text: String) -> Unit,
|
||||
warn: (text: String) -> Unit,
|
||||
info: (text: String) -> Unit,
|
||||
debug: (text: String) -> Unit
|
||||
) {
|
||||
val nonColoredMessage = message.clearAnsiColor()
|
||||
when (type.toLowerCase()) {
|
||||
WARN -> {
|
||||
warn(nonColoredMessage)
|
||||
}
|
||||
ERROR -> {
|
||||
error(nonColoredMessage)
|
||||
}
|
||||
INFO, LOG -> info(nonColoredMessage)
|
||||
DEBUG -> debug(nonColoredMessage)
|
||||
}
|
||||
}
|
||||
|
||||
internal const val ERROR = "error"
|
||||
internal const val WARN = "warn"
|
||||
internal const val INFO = "info"
|
||||
internal const val DEBUG = "debug"
|
||||
internal const val LOG = "log"
|
||||
+2
-29
@@ -17,18 +17,14 @@ import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesClientSetti
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesTestExecutionSpec
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesTestExecutor.Companion.TC_PROJECT_PROPERTY
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.js.NpmPackageVersion
|
||||
import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency
|
||||
import org.jetbrains.kotlin.gradle.targets.js.appendConfigsFromDir
|
||||
import org.jetbrains.kotlin.gradle.targets.js.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.internal.parseNodeJsStackTraceAsJvm
|
||||
import org.jetbrains.kotlin.gradle.targets.js.jsQuoted
|
||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTest
|
||||
import org.jetbrains.kotlin.gradle.testing.internal.reportsDir
|
||||
import org.jetbrains.kotlin.gradle.utils.clearAnsiColor
|
||||
import org.jetbrains.kotlin.gradle.utils.property
|
||||
import org.slf4j.Logger
|
||||
import java.io.File
|
||||
@@ -452,24 +448,7 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
|
||||
}
|
||||
}
|
||||
|
||||
type?.let { processLogMessage(actualText, it) }
|
||||
}
|
||||
|
||||
private fun processLogMessage(
|
||||
message: String,
|
||||
type: String
|
||||
) {
|
||||
val nonColoredMessage = message.clearAnsiColor()
|
||||
when (type.toLowerCase()) {
|
||||
WARN -> {
|
||||
log.warn(nonColoredMessage)
|
||||
}
|
||||
ERROR -> {
|
||||
log.error(nonColoredMessage)
|
||||
}
|
||||
INFO, LOG -> log.info(nonColoredMessage)
|
||||
DEBUG -> log.debug(nonColoredMessage)
|
||||
}
|
||||
type?.let { log.processLogMessage(actualText, it) }
|
||||
}
|
||||
|
||||
private fun processFailedBrowsers(text: String) {
|
||||
@@ -550,11 +529,5 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
|
||||
}
|
||||
}
|
||||
|
||||
private const val ERROR = "error"
|
||||
private const val WARN = "warn"
|
||||
private const val INFO = "info"
|
||||
private const val DEBUG = "debug"
|
||||
private const val LOG = "log"
|
||||
|
||||
private val KARMA_LAUNCHER_MESSAGE = "^.*\\[launcher]: ([\\w\\W]*)\$"
|
||||
.toRegex()
|
||||
Reference in New Issue
Block a user