diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-02-04 12:27:37 +0100 |
---|---|---|
committer | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-02-04 12:33:21 +0100 |
commit | 7e52fb01b79cb6917b0d1ace31dff9c6a26e013f (patch) | |
tree | c3f4b0d0388b6b816dfee44767b34baf727315cf | |
parent | 582f5f89557e943169c10a4fc3d58d99528d8e86 (diff) | |
download | dokka-7e52fb01b79cb6917b0d1ace31dff9c6a26e013f.tar.gz dokka-7e52fb01b79cb6917b0d1ace31dff9c6a26e013f.tar.bz2 dokka-7e52fb01b79cb6917b0d1ace31dff9c6a26e013f.zip |
Implements DokkaLogger interface by MavenDokkaLogger
-rw-r--r-- | core/src/main/kotlin/renderers/FileWriter.kt | 3 | ||||
-rw-r--r-- | runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt | 25 |
2 files changed, 16 insertions, 12 deletions
diff --git a/core/src/main/kotlin/renderers/FileWriter.kt b/core/src/main/kotlin/renderers/FileWriter.kt index 3cb3b5b5..78cfdde7 100644 --- a/core/src/main/kotlin/renderers/FileWriter.kt +++ b/core/src/main/kotlin/renderers/FileWriter.kt @@ -18,11 +18,10 @@ class FileWriter(val context: DokkaContext, override val extension: String): Out createdFiles.add(path) try { -// println("Writing $root/$path$ext") val dir = Paths.get(root, path.dropLastWhile { it != '/' }).toFile() dir.mkdirsOrFail() Files.write(Paths.get(root, "$path$ext"), text.lines()) - } catch (e : Throwable) { + } catch (e: Throwable) { context.logger.error("Failed to write $this. ${e.message}") e.printStackTrace() } diff --git a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt index 950af3e0..403fc773 100644 --- a/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt +++ b/runners/maven-plugin/src/main/kotlin/MavenDokkaLogger.kt @@ -4,19 +4,24 @@ import org.apache.maven.plugin.logging.Log import org.jetbrains.dokka.utilities.DokkaLogger class MavenDokkaLogger(val log: Log) : DokkaLogger { - override fun error(message: String) { - log.error(message) - } + override var warningsCount: Int = 0 + override var errorsCount: Int = 0 override fun debug(message: String) = log.debug(message) - - override fun info(message: String) { - log.info(message) - } - + override fun info(message: String) = log.info(message) override fun progress(message: String) = log.info(message) + override fun warn(message: String) = log.warn(message).also { warningsCount++ } + override fun error(message: String) = log.error(message).also { errorsCount++ } - override fun warn(message: String) { - log.warn(message) + override fun report() { + if (warningsCount > 0 || errorsCount > 0) { + log.info("Generation completed with $warningsCount warning" + + (if(warningsCount == 1) "" else "s") + + " and $errorsCount error" + + if(errorsCount == 1) "" else "s" + ) + } else { + log.info("generation completed successfully") + } } }
\ No newline at end of file |