-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #2944: Changed the logging levels #3491
base: master
Are you sure you want to change the base?
Changes from all commits
e2709c8
3fc8f8e
5c444d1
bb3e436
6bda484
cf3f137
7bc1b4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import org.jetbrains.dokka.generation.GracefulGenerationExit | |
import org.jetbrains.dokka.plugability.DokkaContext | ||
import org.jetbrains.dokka.plugability.DokkaPlugin | ||
import org.jetbrains.dokka.utilities.DokkaLogger | ||
import org.jetbrains.dokka.utilities.LoggingLevel | ||
|
||
/** | ||
* DokkaGenerator is the main entry point for generating documentation | ||
|
@@ -25,12 +26,12 @@ public class DokkaGenerator( | |
|
||
public fun generate() { | ||
timed(logger) { | ||
report("Initializing plugins") | ||
report("Initializing plugins", LoggingLevel.DEBUG) | ||
val context = initializePlugins(configuration, logger) | ||
|
||
runCatching { | ||
context.single(CoreExtensions.generation).run { | ||
logger.progress("Dokka is performing: $generationName") | ||
logger.debug("Dokka is performing: $generationName") | ||
generate() | ||
} | ||
}.exceptionOrNull()?.let { e -> | ||
|
@@ -59,18 +60,29 @@ public class DokkaGenerator( | |
public class Timer internal constructor(startTime: Long, private val logger: DokkaLogger?) { | ||
private val steps = mutableListOf("" to startTime) | ||
|
||
public fun report(name: String) { | ||
logger?.progress(name) | ||
// public fun report(name: String) { | ||
// logger?.progress(name) | ||
// steps += (name to System.currentTimeMillis()) | ||
// } | ||
|
||
public fun report(name: String, logLevel: LoggingLevel) { | ||
when(logLevel) { | ||
LoggingLevel.DEBUG -> logger?.debug(name) | ||
LoggingLevel.PROGRESS -> logger?.progress(name) | ||
LoggingLevel.INFO -> logger?.info(name) | ||
LoggingLevel.WARN -> logger?.warn(name) | ||
LoggingLevel.ERROR -> logger?.error(name) | ||
} | ||
steps += (name to System.currentTimeMillis()) | ||
} | ||
|
||
public fun dump(prefix: String = "") { | ||
logger?.info(prefix) | ||
logger?.debug(prefix) | ||
val namePad = steps.map { it.first.length }.maxOrNull() ?: 0 | ||
val timePad = steps.windowed(2).map { (p1, p2) -> p2.second - p1.second }.maxOrNull()?.toString()?.length ?: 0 | ||
steps.windowed(2).forEach { (p1, p2) -> | ||
if (p1.first.isNotBlank()) { | ||
logger?.info("${p1.first.padStart(namePad)}: ${(p2.second - p1.second).toString().padStart(timePad)}") | ||
logger?.debug("${p1.first.padStart(namePad)}: ${(p2.second - p1.second).toString().padStart(timePad)}") | ||
} | ||
} | ||
} | ||
|
@@ -81,9 +93,9 @@ private fun timed(logger: DokkaLogger? = null, block: Timer.() -> Unit): Timer = | |
try { | ||
block() | ||
} catch (exit: GracefulGenerationExit) { | ||
report("Exiting Generation: ${exit.reason}") | ||
report("Exiting Generation: ${exit.reason}", LoggingLevel.PROGRESS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may be here we can just do try {
block()
report("Exiting Generation")
} catch (exit: GracefulGenerationExit) {
logger.progress(exit.reason)
report("Exiting Generation: ${exit.reason}")
} catch (cause: Throwable) {
report("Exiting Generation: ${cause.message}")
throw cause
} AFAIU |
||
} finally { | ||
report("") | ||
report("", LoggingLevel.PROGRESS) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will mention it here, but it affects all
error->warn
changes.Previously we emitted a lot of errors, but now we report only 3 of them and a lot of warnings. So if project will not set
failOnWarning=true
there could be a lot of warnings which could affect quality of generated HTML.I would expect that users who generate documentation will not check that produced HTML is still fine after new declaration (or anything else) is added/removed. Also those warnings could be easily missed when updating project/Dokka, especially if the project documentation is build on CI.
I'm just trying to understand how it will affect our users. May be we need to set
failOnWarning=true
by default in this case, to prevent users from generation of bad HTML?Or may be we should better specify what is successful documentation generation? As from
DokkaLogger.error
documentation:What do we mean by successful documentation generation? Does HTML with absent data/declarations is considered successful?