name.remal.gradle_plugins.dsl.extensions.org.gradle.api.logging.LoggingManager.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugins-kotlin-dsl Show documentation
Show all versions of gradle-plugins-kotlin-dsl Show documentation
Remal Gradle plugins: gradle-plugins-kotlin-dsl
package name.remal.gradle_plugins.dsl.extensions
import org.gradle.api.logging.LogLevel
import org.gradle.api.logging.LogLevel.ERROR
import org.gradle.api.logging.LogLevel.LIFECYCLE
import org.gradle.api.logging.LoggingManager
inline fun LoggingManager.withCapturedStandardOutput(outputLevel: LogLevel = LIFECYCLE, errorLevel: LogLevel = ERROR, action: () -> R): R {
val prevOutputLevel = standardOutputCaptureLevel
val prevErrorLevel = standardErrorCaptureLevel
try {
captureStandardOutput(outputLevel)
captureStandardError(errorLevel)
return action()
} finally {
captureStandardOutput(prevOutputLevel)
captureStandardError(prevErrorLevel)
}
}