Skip to content

Commit

Permalink
fixed gradle logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolanrensen committed Nov 27, 2024
1 parent faf305f commit d7738b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nl.jolanrensen.docProcessor

import com.intellij.openapi.util.TextRange
import mu.KotlinLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import nl.jolanrensen.docProcessor.gradle.ProcessDocsGradleAction
import nl.jolanrensen.docProcessor.gradle.lifecycle
import org.jetbrains.dokka.CoreExtensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package nl.jolanrensen.docProcessor.gradle

import mu.KLogger
import io.github.oshai.kotlinlogging.DelegatingKLogger
import io.github.oshai.kotlinlogging.KLogger
import org.gradle.api.logging.Logger

fun KLogger.lifecycle(msg: () -> Any?) {
this as DelegatingKLogger<*>
require(underlyingLogger is Logger) { "Logger must be org.gradle.api.logging.Logger for this." }
val underlyingLogger = underlyingLogger as Logger

Expand All @@ -13,6 +15,7 @@ fun KLogger.lifecycle(msg: () -> Any?) {
}

fun KLogger.lifecycle(throwable: Throwable, msg: () -> Any?) {
this as DelegatingKLogger<*>
require(underlyingLogger is Logger) { "Logger must be org.gradle.api.logging.Logger for this." }
val underlyingLogger = underlyingLogger as Logger

Expand All @@ -27,6 +30,7 @@ fun KLogger.lifecycle(throwable: Throwable, msg: () -> Any?) {
* @param message the log message.
*/
fun KLogger.lifecycle(message: String?) {
this as DelegatingKLogger<*>
require(underlyingLogger is Logger) { "Logger must be org.gradle.api.logging.Logger for this." }
(underlyingLogger as Logger).lifecycle(message)
}
Expand All @@ -38,6 +42,7 @@ fun KLogger.lifecycle(message: String?) {
* @param objects the log message parameters.
*/
fun KLogger.lifecycle(message: String?, vararg objects: Any?) {
this as DelegatingKLogger<*>
require(underlyingLogger is Logger) { "Logger must be org.gradle.api.logging.Logger for this." }
(underlyingLogger as Logger).lifecycle(message, *objects)
}
Expand All @@ -49,6 +54,7 @@ fun KLogger.lifecycle(message: String?, vararg objects: Any?) {
* @param throwable the exception to log.
*/
fun KLogger.lifecycle(message: String?, throwable: Throwable?) {
this as DelegatingKLogger<*>
require(underlyingLogger is Logger) { "Logger must be org.gradle.api.logging.Logger for this." }
(underlyingLogger as Logger).lifecycle(message, throwable)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package nl.jolanrensen.docProcessor.gradle

import mu.KotlinLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import nl.jolanrensen.docProcessor.defaultProcessors.ARG_DOC_PROCESSOR
import nl.jolanrensen.docProcessor.defaultProcessors.COMMENT_DOC_PROCESSOR
import nl.jolanrensen.docProcessor.defaultProcessors.EXPORT_AS_HTML_DOC_PROCESSOR
Expand Down

0 comments on commit d7738b3

Please sign in to comment.